Set the motor initialization function.
1.
def
destroy():
2.
motorStop()
3.
GPIO.cleanup()
4.
Set the motor stop function.
1.
def
move(speed, direction, turn, radius=0.6):
2.
#speed = 100
3.
if
direction == 'forward':
4.
if
turn == 'right':
5.
motor_left(0, left_backward, int(speed*radius))
6.
motor_right(1, right_forward, speed)
7.
elif
turn == 'left':
8.
motor_left(1, left_forward, speed)
9.
motor_right(0, right_backward, int(speed*radius))
10.
else:
11.
motor_left(1, left_forward, speed)
12.
motor_right(1, right_forward, speed)
13.
else:
14.
pass
Set the motor rotation function.
if
__name__ == '__main__':
1.
try:
2.
speed_set = 60
3.
setup()
4.
move(speed_set, 'forward', 'no', 0.8)
5.
time.sleep(1.3)
6.
motorStop()
7.
destroy()
8.
except
KeyboardInterrupt:
9.
destroy()
Instantiate the object.
# Release resource
# 0 < radius <= 1
85
Need help?
Do you have a question about the PiCar-Pro and is the answer not in the manual?