-
Notifications
You must be signed in to change notification settings - Fork 0
/
example2.py
48 lines (36 loc) · 1012 Bytes
/
example2.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
#####################################
# example.py
# Written By Ethan Reker 2017
#####################################
import RPi.GPIO as GPIO
import time
import config
import HCSR04
import L298N
#import logic
def turn():
stopCount = 0
print "TURN"
motor_ctrl.setMode("LEFT")
time.sleep(.6)
motor_ctrl.setMode("BACKWARD")
time.sleep(.3)
motor_ctrl.setMode("STOP")
stopCount = 0
config.initialize()
sensorFront = HCSR04.HCSR04(config.TRIG1, config.ECHO, "FRONT")
#sensorRight = HCSR04.HCSR04(config.TRIG2, config.ECHO, "RIGHT")
#sensorLeft = HCSR04.HCSR04(config.TRIG4, config.ECHO, "LEFT")
sensorFront.start()
#sensorRight.start()
#sensorLeft.start()
motor_ctrl = L298N.L298N(22, 11, 12, 13)
motor_ctrl.start()
#logicUnit = logic.LogicalUnit(motor_ctrl, [sensorFront, sensorRight, sensorLeft])
print "Setup Complete"
#logicUnit.start()
while True:
print "Front ", sensorFront.read()
#print "Left ", sensorLeft.read()
#print "Right ", sensorRight.read()
time.sleep(0.5)