EasyManua.ls Logo

SunFounder PiCar-X Kit - Page 53

Default Icon
181 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
SunFounder PiCar-X Kit
(continued from previous page)
for angle in range(-35,0):
px.set_camera_servo2_angle(angle)
time.sleep(0.01)
finally:
px.forward(0)
How it works?
The basic functionality of PiCar-X is in the picarx module, Can be used to control steering gear and wheels, and will
make the PiCar-X move forward, turn in an S-shape, or shake its head.
Now, the libraries to support the basic functionality of PiCar-X are imported. These lines will appear in all the examples
that involve PiCar-X movement.
from picarx import Picarx
import time
The following function with the for loop is then used to make PiCar-X move forward, change directions, and move
the cameras pan/tilt.
px.forward(speed)
px.set_dir_servo_angle(angle)
px.set_camera_servo1_angle(angle)
px.set_camera_servo2_angle(angle)
forward(): Orders the PiCar-X go forward at a given speed.
set_dir_servo_angle: Turns the Steering servo to a specific angle.
set_cam_pan_angle: Turns the Pan servo to a specific angle.
set_cam_tilt_angle: Turns the Tilt servo to a specific angle.
4.3. 1. Let PiCar-X Move 49

Table of Contents

Related product manuals