To follow this guide you'll need the following parts:
- A servo motor. Either a standard servo or 'continuous rotation' servo will work for this guide, but be sure it's a servo motor and not a DC motor (which requires a different method of driving it). Check out the Adafruit Motor Selection Guide for more details on the different types of motors. If in doubt grab a small micro servo to experiment with and follow this guide.
- A ~5 volt power supply for the servo. Servos and motors in general can pull a surprisingly large amount of power, particularly when they're stopped or meeting resistance. In some cases they can pull so much power that it damages or overwhelms your development board! To prevent issues like this it's highly recommended to use a separate power supply for the motors in your project. A 4x AA battery pack is a perfect option for powering a few servos.
- A microcontroller running CircuitPython or a Raspberry Pi running Adafruit Blinka. If you're controlling servos from CircuitPython you'll need a board like the Feather M0 basic which can be loaded with CircuitPython firmware. Adafruit Blinka enables you to use CircuitPython modules and libraries on Raspberry Pi and other single board computers. This guide will also show basic servo code for Arduino too.
- Breadboard and jumper wires. You'll need these parts to connect components to your development board.
Servo motors have three wires to connect to your board:
- Power - Typically a red wire which must be driven by 3-6 volts. However always check your servo datasheet or product information to make sure it's safe to power with the voltage you intend to provide. If the voltage is too high it might damage the servo!
- Ground - Typically a brown or black wire which must be connect to both your board and servo power supply grounds.
- Signal - Typically an orange or yellow wire. This wire is connected to a PWM or pulse-width modulation output on your development board. For boards like the Feather M0 look for pins with a squiggly line next to them to see those that support PWM output. For other boards check the product information or guide to see which outputs support PWM signals.
You might see a fourth wire coming from your servo motor too. Some advanced servos provide an output to help determine the position of the motor. You can ignore this fourth wire as it won't be used in this guide. However be absolutely sure you're using a servo motor and not a stepper or other type of motor if you see more or less than three wires coming from your device!
Here's an example of wiring a servo to a Feather M0 and a 4x AA power supply:
Here is an example of wiring a servo to a Raspberry Pi:
See the guide CircuitPython Essentials - CircuitPython Servo for wiring for the Adafruit Trinket, Gemma, Circuit Playground Express, Feather, and Metro.