Hardware Reference
In-Depth Information
3. Connect the yellow wire from the servo to digital pin 9. It should look
something like Figure 3-19 or Figure 3-20 .
4. In the Arduino IDE, enter the code from Example 3-4 into a new sketch.
5. With the Galileo powered on and connected to your computer via USB,
upload the sketch to the board.
Figure 3-19. Wiring up a hobby servo to Galileo
If you have everything wired up correctly, you should see the servo swing
back and forth (see Example 3-4 )!
Example 3-4. Servo Test
#include <Wire.h>
#include <Servo.h> //
int servoPin = 9 ;
Servo myServo ; //
void setup () {
myServo . attach ( servoPin ); //
}
void loop () {
myServo . write ( 0 ); //
delay ( 1000 );
Search WWH ::




Custom Search