EasyManuals Logo

Freenove 4WD Smart Car Board for Raspberry Pi User Manual

Default Icon
132 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #82 background imageLoading...
Page #82 background image
Need support? support.freenove.com
78
Chapter 3 Module test (necessary)
Servo
Enter the following commands in the terminal to test servos.
If the terminal displays the directory as below (where test.py is located), you can directly execute the test.py
command.
1. If not, execute the cd command:
cd ~/Freenove_4WD_Smart_Car_Kit_for_Raspberry_Pi/Code/Server
2. Execute test.py command:
sudo python test.py Servo
Result:
The servo 0 repeats rotating from left to right and then from right to left. The servo 1 repeats rotating from
bottom to top and then from top to bottom. You can press Ctrl + Cto end the program.
The code is as below:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from servo import *
pwm=Servo()
def test_Servo():
try:
while True:
for i in range(50,110,1):
pwm.setServoPwm('0',i)
time.sleep(0.01)
for i in range(110,50,-1):
pwm.setServoPwm('0',i)
time.sleep(0.01)
for i in range(80,150,1):
pwm.setServoPwm('1',i)
time.sleep(0.01)
for i in range(150,80,-1):
pwm.setServoPwm('1',i)
time.sleep(0.01)
except KeyboardInterrupt:

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Freenove 4WD Smart Car Board for Raspberry Pi and is the answer not in the manual?

Freenove 4WD Smart Car Board for Raspberry Pi Specifications

General IconGeneral
BrandFreenove
Model4WD Smart Car Board for Raspberry Pi
CategoryMicrocontrollers
LanguageEnglish