import sys, getopt import RPi.GPIO as GPIO import time delay = 3 steps = int(sys.argv[1]) print('Schritte: ', steps) GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) coil_A_1_pin = 12 # gelb coil_B_1_pin = 16 # schwarz coil_A_2_pin = 20 # orange coil_B_2_pin = 21 # braun # anpassen, falls andere Sequenz StepCount = 4 Seq = list(range(0, StepCount)) Seq[0] = [1,0,0,0] Seq[1] = [0,1,0,0] Seq[2] = [0,0,1,0] Seq[3] = [0,0,0,1] #GPIO.setup(enable_pin, GPIO.OUT) GPIO.setup(coil_A_1_pin, GPIO.OUT) GPIO.setup(coil_A_2_pin, GPIO.OUT) GPIO.setup(coil_B_1_pin, GPIO.OUT) GPIO.setup(coil_B_2_pin, GPIO.OUT) #GPIO.output(enable_pin, 1) def setStep(w1, w2, w3, w4): GPIO.output(coil_A_1_pin, w1) GPIO.output(coil_A_2_pin, w2) GPIO.output(coil_B_1_pin, w3) GPIO.output(coil_B_2_pin, w4) def forward(delay, steps): for i in range(steps): for j in range(StepCount): setStep(Seq[j][0], Seq[j][1], Seq[j][2], Seq[j][3]) time.sleep(delay) def backwards(delay, steps): for i in range(steps): for j in reversed(range(StepCount)): setStep(Seq[j][0], Seq[j][1], Seq[j][2], Seq[j][3]) time.sleep(delay) if steps >0: forward(int(delay) / 1000.0, int(steps)) if steps <0: backwards(int(delay) / 1000.0, abs(steps)) setStep(0,0,0,0)