forked from peddivarshith/3dPrintedMicroscope
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Motor_Movement.py
85 lines (71 loc) · 2.17 KB
/
Motor_Movement.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
import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(16,GPIO.OUT,initial=GPIO.LOW) # Dir pin 3 of shield x- dir motor
GPIO.setup(18,GPIO.OUT,initial=GPIO.LOW) # Step Pin 6 of shield
GPIO.setup(22,GPIO.OUT,initial=GPIO.LOW) # Dir pin 4 of shield y-dir motor
GPIO.setup(24,GPIO.OUT,initial=GPIO.LOW) # Step pin 7 of shield
GPIO.setup(11,GPIO.OUT,initial=GPIO.HIGH)#Enable bar pin 8 of shield => Initially the motor is not enabled
GPIO.setup(13,GPIO.OUT,initial=GPIO.LOW) #Dir pin 2 of shield
GPIO.setup(31,GPIO.OUT,initial=GPIO.LOW) #Step pin 5 of shield
def zplus():
GPIO.output(11,GPIO.LOW)
GPIO.output(13,GPIO.LOW)
for i in range(0,1):
GPIO.output(31,GPIO.HIGH)
time.sleep(0.02)
GPIO.output(31,GPIO.LOW)
time.sleep(0.02)
print("ZPLUS")
GPIO.output(11,GPIO.HIGH)
def zminus():
GPIO.output(11,GPIO.LOW)
GPIO.output(13,GPIO.HIGH)
for i in range(0,1):
GPIO.output(31,GPIO.HIGH)
time.sleep(0.02)
GPIO.output(31,GPIO.LOW)
time.sleep(0.02)
print("ZMINUS")
GPIO.output(11,GPIO.HIGH)
def rightstep():
GPIO.output(11,GPIO.LOW)
GPIO.output(16,GPIO.LOW)
for i in range(0,1):
GPIO.output(18,GPIO.HIGH)
time.sleep(0.02)
GPIO.output(18,GPIO.LOW)
time.sleep(0.02)
print("RIGHT")
GPIO.output(11,GPIO.HIGH)
def leftstep():
GPIO.output(11,GPIO.LOW)
GPIO.output(16,GPIO.HIGH)
for i in range(0,1):
GPIO.output(18,GPIO.HIGH)
time.sleep(0.02)
GPIO.output(18,GPIO.LOW)
time.sleep(0.02)
print("LEFT")
GPIO.output(11,GPIO.HIGH)
def upwardstep():
GPIO.output(11,GPIO.LOW)
GPIO.output(22,GPIO.LOW)
for i in range(0,1):
GPIO.output(24,GPIO.HIGH)
time.sleep(0.02)
GPIO.output(24,GPIO.LOW)
time.sleep(0.02)
print("UPWARD")
GPIO.output(11,GPIO.HIGH)
def downwardstep():
GPIO.output(11,GPIO.LOW)
GPIO.output(22,GPIO.HIGH)
for i in range(0,1):
GPIO.output(24,GPIO.HIGH)
time.sleep(0.02)
GPIO.output(24,GPIO.LOW)
time.sleep(0.02)
print("DOWNWARD")
GPIO.output(11,GPIO.HIGH)