| 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
 | import time
import sys
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
stepPins = [26,24,22,19]
waitTime = 0.000001
for pin in stepPins:
    print "Setup pins"
    GPIO.setup(pin,GPIO.OUT)
    GPIO.output(pin, False)
stepCounter = 0
stepCount = 8
Seq = []
Seq = range(0, stepCount)
Seq[0] = [1,0,0,0]
Seq[1] = [1,1,0,0]
Seq[2] = [0,1,0,0]
Seq[3] = [0,1,1,0]
Seq[4] = [0,0,1,0]
Seq[5] = [0,0,1,1]
Seq[6] = [0,0,0,1]
Seq[7] = [1,0,0,1]
 
# Choose a sequence to use
maxSteps = 1600
completedSteps = 0
 
# Start main loop
while completedSteps != maxSteps:
 
  for pin in range(0, 4):
    xpin = stepPins[pin]
    pinVal = Seq[stepCounter][pin]
    if pinVal!=0:
      #print " Step %i Enable %i" %(StepCounter,xpin)
      GPIO.output(xpin, True)
    else:
      GPIO.output(xpin, False)
 
  stepCounter += 1
  completedSteps +=1
  print " Stepcounter: %i" %(stepCounter)
  if (stepCounter==stepCount):
    stepCounter = 0
  if (stepCounter<0):
    stepCounter = stepCount
  time.sleep(waitTime)
 |