import time import sys from gpiozero import PWMOutputDevice as stepper IN1 = stepper(12, active_high=True, initial_value=0, frequency=12000) #pul/pwm IN2 = stepper(23) #dir #IN3 = stepper(24) #ena stepPins = [IN1] seq = [ [1,0,0,1], [1,0,0,0], [1,1,0,0], [0,1,1,0], [0,1,1,0], [0,0,1,1], [0,0,1,1], [0,0,0,1] ] stepCount = len(seq) gear = 0 waitTime = gear * 0.0001 def startMotor(direction="LR"): stepCounter = 0 if direction == "RL": IN2.on() else: IN2.off() while True: for pin in range(0,1): xPin=stepPins[pin] if seq[stepCounter][pin]!=0: xPin.on() else: xPin.off() stepCounter += 1 if (stepCounter >= stepCount): stepCounter = 0 if (stepCounter < 0): stepCounter = stepCount + 1 time.sleep(waitTime) startMotor("LR")