Objective:
In this project, we will use Raspberry Pi to send command through GPIO to Servo Motor and control its rotation action.
If you don’t know what is GPIO layout, check our tutorial How to read Raspberry Pi i/o pin diagram (GPIO pin graph)
Parts:
1 pc | Raspberry Pi 2/3/zero | |
1 pc | 8GB MicroSD memory card preinstalled Raspbian OS. | |
1 pc | Servo Motor | |
1 pc | breadboard | |
1 pc | GPIO breakout kit(optional) |
Prerequisite:
Raspbian should be upgraded to latest version in order to support RPI.GPIO module
Please run following commands in shell:
Caution: Unlike Arduino board 5V input voltage, Raspberry GPIO pin accept only 3 Volt. Wrong voltage input might damage the Pi board. Please be very careful!
download python code pi-servo.py
Please typing following shell commands to download python files( pi-servo.py):
wget http://osoyoo.com/driver/pi-servo.py
Finally, run following command in shell window:
sudo python pi-servo.py
You will see following manual in terminal window:
l = move to the left
r = move to the right
m = move to the middle
t = test sequence
q = stop and exit
You can type above 5 options(l,r,m,t,q) and control the servo motion accordingly.
Video Demo:
DownLoad Url osoyoo.com
You must be logged in to post a comment.
The command raspi-config on the latest Raspbian Pi does not show I2C or SPI under Advanced Options. I am, however, able to see these options when I use the GUI to get to Raspberry Pi Configuration. However, even enabling I2C and SPI there, I am still not able to get the servo motor to move.
we download the lastest raspbian Lite on the raspberry offical website and we enter sudo raspi-config and find the advance option and enable I2C and SPI.
What’s more, we can config when we enter preference and then in interfaces to enable I2C and SPI.
The text on the circuit graph calls for the yellow control wire to be connected to Pin 11 (GPIO 18). But Pin 11 is GPIO 17, and that seems to be what the diagram shows.
We have changed the circuit graph.
After looking at you python code, I need a quick explanation of how duty cycle relates to PWM, since you product spec sheet is uses PWM. I tried a few quick calcs, but I dont seem to be getting the same numbers as those found on your product spec sheet for the servo.
Just trying to learn. Thanks
Awesome article post. Really looking forward to reading more.WWW.batplcbd.com