-
Notifications
You must be signed in to change notification settings - Fork 2
/
explorerrobot_b.py
45 lines (33 loc) · 1.02 KB
/
explorerrobot_b.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
import explorerhat
from time import sleep
from guizero import App, PushButton, Text
def backwards():
explorerhat.motor.one.forward(100)
explorerhat.motor.two.backward(100)
sleep(1)
explorerhat.motor.one.stop()
explorerhat.motor.two.stop()
def forwards():
explorerhat.motor.two.forward(100)
explorerhat.motor.one.backward(100)
sleep(1)
explorerhat.motor.one.stop()
explorerhat.motor.two.stop()
def turns_right():
explorerhat.motor.two.backward(100)
sleep(1)
explorerhat.motor.two.stop()
def turns_left():
explorerhat.motor.one.forward(100)
sleep(1)
explorerhat.motor.one.stop()
def stops():
explorerhat.motor.one.stop()
explorerhat.motor.two.stop()
app = App("Robot controller")
drive = PushButton(app, forwards, text="Forwards")
reverse = PushButton(app, backwards, text="Backwards")
right = PushButton(app, turns_right, text="Right Turn")
left = PushButton(app, turns_left, text="Left Turn")
stop = PushButton(app, stops, text="Stop")
app.display