Ch-5 clean
This commit is contained in:
parent
5c4ecaeb13
commit
481cac28de
@ -12,6 +12,7 @@ motor_A2.direction = digitalio.Direction.OUTPUT
|
|||||||
motor_B1.direction = digitalio.Direction.OUTPUT
|
motor_B1.direction = digitalio.Direction.OUTPUT
|
||||||
motor_B2.direction = digitalio.Direction.OUTPUT
|
motor_B2.direction = digitalio.Direction.OUTPUT
|
||||||
|
|
||||||
|
|
||||||
def stop():
|
def stop():
|
||||||
motor_A1.value = False
|
motor_A1.value = False
|
||||||
motor_A2.value = False
|
motor_A2.value = False
|
||||||
|
|||||||
@ -12,6 +12,7 @@ motor_A2.direction = digitalio.Direction.OUTPUT
|
|||||||
motor_B1.direction = digitalio.Direction.OUTPUT
|
motor_B1.direction = digitalio.Direction.OUTPUT
|
||||||
motor_B2.direction = digitalio.Direction.OUTPUT
|
motor_B2.direction = digitalio.Direction.OUTPUT
|
||||||
|
|
||||||
|
|
||||||
def stop():
|
def stop():
|
||||||
motor_A1.value = False
|
motor_A1.value = False
|
||||||
motor_A2.value = False
|
motor_A2.value = False
|
||||||
|
|||||||
@ -12,6 +12,7 @@ motor_A2.direction = digitalio.Direction.OUTPUT
|
|||||||
motor_B1.direction = digitalio.Direction.OUTPUT
|
motor_B1.direction = digitalio.Direction.OUTPUT
|
||||||
motor_B2.direction = digitalio.Direction.OUTPUT
|
motor_B2.direction = digitalio.Direction.OUTPUT
|
||||||
|
|
||||||
|
|
||||||
def stop():
|
def stop():
|
||||||
motor_A1.value = False
|
motor_A1.value = False
|
||||||
motor_A2.value = False
|
motor_A2.value = False
|
||||||
|
|||||||
@ -1,20 +1,22 @@
|
|||||||
import time
|
import time
|
||||||
import robot
|
import robot
|
||||||
|
|
||||||
|
|
||||||
def straight(speed, duration):
|
def straight(speed, duration):
|
||||||
robot.set_left(speed)
|
robot.set_left(speed)
|
||||||
robot.set_right(speed)
|
robot.set_right(speed)
|
||||||
time.sleep(duration)
|
time.sleep(duration)
|
||||||
|
|
||||||
|
|
||||||
def left(speed, duration):
|
def left(speed, duration):
|
||||||
robot.set_left(0)
|
robot.set_left(0)
|
||||||
robot.set_right(speed)
|
robot.set_right(speed)
|
||||||
time.sleep(duration)
|
time.sleep(duration)
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for n in range(0, 4):
|
for n in range(0, 4):
|
||||||
straight(0.6, 1.0)
|
straight(0.6, 1.0)
|
||||||
left(0.6, 1)
|
left(0.6, 1)
|
||||||
finally:
|
finally:
|
||||||
robot.stop()
|
robot.stop()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user