Hardware Reference
In-Depth Information
Arduino and servos. Your kit is now ready to move. Let's start with a simple program that
sets all of the servos to their middle position, and then takes in a command to move just
one of the servos to a specific angle. This will help you understand how your robot is con-
figured, as shown in the following screenshot:
The preceding code includes a significant number of Serial.println() functions;
these are there to show you what is happening. The key statement for servo control is
pwm.setPWM(servo, 0, pwmValue); . This statement sends out a PWM signal
that the servo motor uses to determine the desired angle. The servo variable selects the
servo to control, the 0 variable sets when the PWM pulse starts (you'll use 0 for this ap-
plication), and the pwmValue variable sets the length of the pulse. You can now see how
your robot can be programmed to be moved by performing the following steps:
1. One step you'll probably want to do is adjust the mechanical position of your ser-
vos. To do this, run the program so that all of the servos are set to their middle
location.
Search WWH ::




Custom Search