Welcome to 16-channel Servo Debugging Board repository
Serial control servo
1. Learning goals
In this course, we mainly learn to use Raspberry Pi and 16-channels servo debugging board to control the servo through serial port.
2. Preparation
Connect the TXD and RXD of the module to the IO15 and IO14 pins of the Raspberry Pi board. VCC and GND are connected to 3.3V and GND of Raspberry Pi board respectively. As shown below.
3. Assign the serial port of the Raspberry Pi
3.1 Raspberry Pi needs to assign ttyAMA0 port to GPIO serial port TXD0, RXD0, the specific method is as follows.
Enter sudo raspi-config to enter the Raspberry Pi system configuration interface, and select the fifth Interfacing Options:
Enter “P6 Serial”.
Choose to close the serial port log in function and open the hardware serial port debugging function.
Click “OK”.
Exit raspi-config settings, and restart the Raspberry Pi according to the prompts.
3.2 Edit the config.txt file in the /boot directory: sudo nano /boot/config.txt
Add the following two lines to the end:
dtoverlay=pi3-miniuart-bt
force_turbo=1
As shown below.
3.3 Press “Ctrl+O” save file. Press “Ctrl+X” save file.
3.4 Input following command to restart Raspebrry Pi.
sudo reboot
After restarting the Raspberry Pi, enter ls /dev -al , you can see that the two serial ports have changed positions. As shown below.
4. Code
Please refer to 16CServo-uart.py
Configure the serial port.
Serial port control servo function
Set the servo S1 angle to 0
4. Running code
Input following command in the terminal to run the program.
python 16CServo-uart.py
5. Phenomenon
After the program is run successfully. The servo will rotate 0°, after 2s it will rotate 180°.