Files
Robotics-at-Home-with-Raspb…/ch-5/5-path/pwm_drive_square.py
T
Danny Staple 481cac28de Ch-5 clean
2022-03-20 22:24:56 +00:00

23 lines
346 B
Python

import time
import robot
def straight(speed, duration):
robot.set_left(speed)
robot.set_right(speed)
time.sleep(duration)
def left(speed, duration):
robot.set_left(0)
robot.set_right(speed)
time.sleep(duration)
try:
for n in range(0, 4):
straight(0.6, 1.0)
left(0.6, 1)
finally:
robot.stop()