forked from skiwithpete/seenancy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmulti_stepper_3a.py
executable file
·80 lines (70 loc) · 1.97 KB
/
multi_stepper_3a.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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
axisx = [4,17,27,22]
axisy = [10,9,11,7]
axisz = [15,18,23,24]
for pin in axisx + axisy + axisz:
GPIO.setup(pin,GPIO.OUT)
GPIO.output(pin,0)
seq = [ [1,0,0,0],
[1,1,0,0],
[0,1,0,0],
[0,1,1,0],
[0,0,1,0],
[0,0,1,1],
[0,0,0,1],
[1,0,0,1] ]
try:
while True:
stepsx = raw_input("How many X steps forward? ")
stepsy = raw_input("How many Y steps forward? ")
stepsz = raw_input("How many Z steps forward? ")
if int(stepsx) < 0:
seq.reverse()
for i in range(-int(stepsx)):
for halfstep in range(8):
for pin in range(4):
GPIO.output(axisx[pin], seq[halfstep][pin])
time.sleep(0.001)
seq.reverse()
else:
for i in range(int(stepsx)):
for halfstep in range(8):
for pin in range(4):
GPIO.output(axisx[pin], seq[halfstep][pin])
time.sleep(0.001)
if int(stepsy) < 0:
seq.reverse()
for i in range(-int(stepsy)):
for halfstep in range(8):
for pin in range(4):
GPIO.output(axisy[pin], seq[halfstep][pin])
time.sleep(0.001)
seq.reverse()
else:
for i in range(int(stepsy)):
for halfstep in range(8):
for pin in range(4):
GPIO.output(axisy[pin], seq[halfstep][pin])
time.sleep(0.001)
if int(stepsz) < 0:
seq.reverse()
for i in range(-int(stepsz)):
for halfstep in range(8):
for pin in range(4):
GPIO.output(axisz[pin], seq[halfstep][pin])
time.sleep(0.001)
seq.reverse()
else:
for i in range(int(stepsz)):
for halfstep in range(8):
for pin in range(4):
GPIO.output(axisz[pin], seq[halfstep][pin])
time.sleep(0.001)
# End program cleanly with keyboard
except KeyboardInterrupt:
print " Quit"
GPIO.cleanup()