-
Notifications
You must be signed in to change notification settings - Fork 0
/
linear_test.py
60 lines (40 loc) · 914 Bytes
/
linear_test.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
#!/usr/bin/python
import time
import RPi.GPIO as GPIO
# ===========================================================================
# Example Code
# ===========================================================================
# L298N setup code
# Define Outputs to L298N
en = 7
in1 = 35
in2 = 31
inpsec = 1.86 #2
# enB =
# in3 =
# in4 =
desireddistance = 10
calctime = desireddistance/inpsec
def up():
GPIO.output(in1,GPIO.HIGH)
GPIO.output(in2,GPIO.LOW)
def down():
GPIO.output(in1,GPIO.LOW)
GPIO.output(in2,GPIO.HIGH)
#GPIO.cleanup()
GPIO.setmode(GPIO.BOARD)
GPIO.setup(in1,GPIO.OUT)
GPIO.setup(in2,GPIO.OUT)
GPIO.setup(en,GPIO.OUT)
GPIO.output(in1,GPIO.LOW)
GPIO.output(in2,GPIO.LOW)
GPIO.output(en, GPIO.HIGH)
up()
time.sleep(calctime)
print (calctime)
down()
time.sleep(calctime)
GPIO.output(in1,GPIO.LOW)
GPIO.output(in2,GPIO.LOW)
GPIO.output(en, GPIO.LOW)
GPIO.cleanup()