-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIFTest.py
62 lines (44 loc) · 1.37 KB
/
IFTest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from pybricks.hubs import InventorHub
from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop
from pybricks.robotics import DriveBase, GyroDriveBase
from pybricks.tools import wait, StopWatch
hub = InventorHub()
left_motor = Motor(Port.C, Direction.COUNTERCLOCKWISE)
right_motor = Motor(Port.D)
wheel_diameter = 44
axel_track = 96
drive_base = GyroDriveBase(left_motor, right_motor, wheel_diameter,axel_track)
drive_base.settings(300,500,100,200)
def I_AM_WAITING():
count = 0
l=2
while (count < l) :
drive_base.turn(360)
drive_base.straight(100)
count = count +1
if count == l :
drive_base.straight(400)
count = count -1
if not count == 0 :
drive_base.straight(-400)
count = count +1
def I_AM_WAITING_NOT():
wait (200)
drive_base.straight(100)
drive_base.turn(90)
drive_base.straight(100)
drive_base.turn(90)
drive_base.straight(100)
drive_base.turn(90)
drive_base.straight(100)
drive_base.turn(90)
while True:
pressed = hub.buttons.pressed()
if (Button.LEFT in pressed):
drive_base.straight(100)
I_AM_WAITING()
hub.light.on(Color.GREEN)
if (Button.RIGHT in pressed):
I_AM_WAITING_NOT()
hub.light.on(Color.RED)