Chapter 5 examples

This commit is contained in:
Danny Staple
2021-12-07 21:34:30 +00:00
parent 4cdabd2403
commit 1f9e6b8f91
20 changed files with 311 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
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()