Created
November 30, 2019 15:17
-
-
Save freegroup/2c7f6938932fac0fff1a3c5771de562c to your computer and use it in GitHub Desktop.
Revisions
-
freegroup created this gist
Nov 30, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,57 @@ # Stel de GPIO pinnen in voor de stappenmotor: import sys import time import RPi.GPIO as GPIO # Use BCM GPIO references # instead of physical pin numbers GPIO.setmode(GPIO.BCM) StepPins = [23,24,25,4] # Set all pins as output for pin in StepPins: GPIO.setup(pin,GPIO.OUT) GPIO.output(pin, False) # Define advanced sequence # as shown in manufacturers datasheet Seq = [[1,0,0,1], [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]] StepCount = len(Seq) StepDir = 1 # Set to 1 or 2 for clockwise # Set to -1 or -2 for anti-clockwise WaitTime = 0.001 # Initialise variables StepCounter = 0 # Start main loop while True: for pin in range(0, 4): xpin = StepPins[pin]# if Seq[StepCounter][pin]!=0: GPIO.output(xpin, True) else: GPIO.output(xpin, False) StepCounter += StepDir # If we reach the end of the sequence # start again if (StepCounter>=StepCount): StepCounter = 0 if (StepCounter<0): StepCounter = StepCount+StepDir # Wait before moving on time.sleep(WaitTime)