EasyManua.ls Logo

Keyestudio KS0079 - Page 93

Default Icon
142 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
keyestudio
www.keyestudio.com
93
The rotate angle of the servo motor is controlled by regulating the duty cycle of the
PWM(Pulse-Width Modulation) signal. The standard cycle of the PWM signal is 20ms(50Hz).
Theoretically, the width is distributed between 1ms-2ms, but in fact, it's between 0.5ms-2.5ms.
The width corresponds the rotate angle from 0° to 180°. But note that for different brand motor,
the same signal may have different rotating angle.
With some basic knowledge, let's learn how to control a servomotor. In this experiment, you only
need a servomotor and several jumper wires.
Hardware Required
9G Servo Motor*1
Breadboard Jumper Wire*several
Connection & Sample Code
There are two ways to control a servomotor with Arduino. One is to use a common digital sensor
port of Arduino to produce square wave with different duty cycle to simulate PWM signal and use
that signal to control the positioning of the motor.
Another way is to directly use the Servo function of the Arduino to control the motor. In this way,
the program will be more easier but it can only control two-contact motor because of the servo
function, only digital pin 9 and 10 can be used. The Arduino drive capacity is limited. So if you
need to control more than one motor, you will need external power.
Method 1:
Connection for UNO R3: