November 17, 2017 • 17 • 4.5
The Raspberry allows for various robotics projects. The servo motor is a component often used in this field. It's not a simple motor; it's smart. We can ask it to reach a certain position and it will execute the command without the need for end-stop sensors, etc. Unfortunately, its travel is only 180°. Other types of servos exist, such as winch servos. They offer more than 3 turns of travel but are more expensive.
To control a servo motor with a Raspberry Pi, you need:
Once you have everything, you can move on to wiring.
The servo motor has 3 wires:
Red wire: +5V;
Black wire: GND, 0V;
White/yellow wire: data line, where commands flow from the Raspberry to the Servo.
To power the servo, it is better to use an external 5V supply, especially if your Raspberry power supply provides little current.
Wire the servo as follows:
Once everything is properly wired, we can move on to programming. To control the servo motor, here is a Python program that lets you:
Ask the servo to reach a position (an angle) and hold it for a set duration,
Have it sweep back and forth from 0° to 180°
This program is of course meant to be modified and adapted to your project needs—your turn to play!
Choose and use a camera on Raspberry Pi
Get temperature with a DS18B20 sensor
Raspberry Pi 5 (8 GB version)
94.48 €
Raspberry Pi camera 5MP 1080p
12.95 €




4.5/5 | 13 votes