-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwheels.py
61 lines (51 loc) · 1.46 KB
/
wheels.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
import RPi.GPIO as gpio
import time
class MotorWheels():
def __init__(self):
gpio.setmode(gpio.BCM)
gpio.setup(17, gpio.OUT)
gpio.setup(27, gpio.OUT)
gpio.setup(23, gpio.OUT)
gpio.setup(24, gpio.OUT)
def forward(self, sec):
gpio.output(17, True)
gpio.output(27, False)
gpio.output(23, True)
gpio.output(24, False)
time.sleep(sec)
def backward(self, sec):
gpio.output(17, False)
gpio.output(27, True)
gpio.output(23, False)
gpio.output(24, True)
time.sleep(sec)
def forwardright(self, sec):
gpio.output(17, True)
gpio.output(27, False)
gpio.output(23, False)
gpio.output(24, False)
time.sleep(sec)
def backwardright(self, sec):
gpio.output(17, False)
gpio.output(27, True)
gpio.output(23, False)
gpio.output(24, False)
time.sleep(sec)
def forwardleft(self, sec):
gpio.output(17, False)
gpio.output(27, False)
gpio.output(23, True)
gpio.output(24, False)
time.sleep(sec)
def backwardleft(self, sec):
gpio.output(17, False)
gpio.output(27, False)
gpio.output(23, False)
gpio.output(24, True)
time.sleep(sec)
def stop(self):
gpio.output(17, False)
gpio.output(27, False)
gpio.output(23, False)
gpio.output(24, False)
time.sleep(0.5)