EasyManua.ls Logo

ADEEPT PiCar-Pro - Page 88

ADEEPT PiCar-Pro
178 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...
85
Set the motor initialization function.
1. def destroy():
2. motorStop()
3. GPIO.cleanup() # Release resource
4.
Set the motor stop function.
1. def move(speed, direction, turn, radius=0.6): # 0 < radius <= 1
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.

Related product manuals