-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
75 lines (65 loc) · 1.72 KB
/
config.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
################################################################
# THIS FILE MUST BE CONFIGURED BEFORE USING ANY OF THE MODULES #
# Below are variables which indicate which pins on the PI will #
# be used. #
# - Replace "" with actual pin # without quotes.
################################################################
import RPi.GPIO as GPIO
import threading
thread_lock = threading.Lock()
mode = "BOARD" #define the pin numbering system to be used. (BOARD, BCM)
warnings = "OFF" #change to "ON" to enable warnings
# L298N Pins
A_FORWARD = 22
A_REVERSE = 11
B_FORWARD = 12
B_REVERSE = 13
# HC_SR04 Pins
TRIG1 = 31
TRIG2 = 35
TRIG3 = 37
TRIG4 = ""
TRIG5 = ""
ECHO1 = 32
ECHO2 = 36
ECHO3 = 38
# SG90 Pins
SERVO1 = ""
SERVO2 = ""
SERVO3 = ""
def setup_pin(pinNo, mode):
if pinNo != "":
try:
if mode:
GPIO.setup(pinNo, GPIO.IN)
print "Pin ", pinNo, " set as Input"
else:
GPIO.setup(pinNo, GPIO.OUT)
print "Pin ", pinNo, " set as Output"
except:
print "Error setting up pin ", pinNo
def initialize():
if mode == "BOARD":
print "Using BOARD numbering system."
GPIO.setmode(GPIO.BOARD)
else:
print "Using BCM numbering system."
GPIO.setmode(GPIO.BCM)
if warnings == "OFF":
print "Warnings OFF."
GPIO.setwarnings(False)
# setup_pin(A_FORWARD, 0)
# setup_pin(A_REVERSE, 0)
# setup_pin(B_FORWARD, 0)
# setup_pin(B_REVERSE, 0)
# setup_pin(TRIG1, 0)
# setup_pin(TRIG2, 0)
# setup_pin(TRIG3, 0)
# setup_pin(ECHO1, None)
# setup_pin(ECHO2, None)
# setup_pin(ECHO3, None)
# setup_pin(TRIG4, 0)
# setup_pin(TRIG5, 0)
# setup_pin(SERVO1, 0)
# setup_pin(SERVO2, 0)
# setup_pin(SERVO3, 0)