First Steps with a Servo Motor

The Arduino IDE comes with a library for controlling servo motors that we’ll use for our first experiments. The following figure shows a basic circuit for connecting an Arduino to a servo motor. Connect the ground wire to one of the Arduino’s GND pins, connect power to the Arduino’s 5V pin, and connect the control line to pin 9.

images/basic_servo.png

Please note that this works only for a 5V servo! Many cheap servos use 9V, and in that case you need an external power supply, and you can no longer connect the servo to the Arduino’s 5V pin. If you have a 9V servo, attach an external power supply, such as an AC-to-DC adapter or a DC power ...

Get Arduino: A Quick-Start Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.