-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirections.py
116 lines (95 loc) · 2.07 KB
/
directions.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
"""
This file contains functions for
driving the car.
"""
import RPi.GPIO as gpio
import time
def init():
"""
Sets up GPIO pins
for driving car.
"""
gpio.setmode(gpio.BOARD)
gpio.setup(7, gpio.OUT)
gpio.setup(11, gpio.OUT)
gpio.setup(13, gpio.OUT)
gpio.setup(15, gpio.OUT)
def start():
"""
Put car in indefinite forward
direction, for use in autonomous driving.
"""
gpio.output(7, True)
gpio.output(11, False)
gpio.output(13, False)
gpio.output(15, True)
def stop():
"""
Stops car, for use in autonomous driving.
"""
gpio.output(7, False)
gpio.output(11, False)
gpio.output(13, False)
gpio.output(15, False)
def cleanup():
gpio.cleanup()
def forward():
"""
Drive car forward, for use in
user controlled driving.
"""
# put in forward direction
gpio.output(7, True)
gpio.output(11, False)
gpio.output(13, False)
gpio.output(15, True)
def reverse():
"""
Drive car in reverse, for use in
user controlled driving.
"""
# put in reverse direction
gpio.output(7, False)
gpio.output(11, True)
gpio.output(13, True)
gpio.output(15, False)
def right():
"""
Drive car right, for use in
user controlled driving.
"""
# put in right direction
gpio.output(7, False)
gpio.output(11, False)
gpio.output(13, False)
gpio.output(15, True)
def left():
"""
Drive car left, for use in
user controlled driving.
"""
# put in left direction
gpio.output(7, True)
gpio.output(11, False)
gpio.output(13, False)
gpio.output(15, False)
def pivot_left():
"""
Pivot car left, for use in
user controlled driving.
"""
# put in left pivot
gpio.output(7, True)
gpio.output(11, False)
gpio.output(13, True)
gpio.output(15, False)
def pivot_right():
"""
Pivot car right, for use in
user controlled driving.
"""
# put in rightpivot
gpio.output(7, False)
gpio.output(11, True)
gpio.output(13, False)
gpio.output(15, True)