Trying to run the below on an RPi to get a stepper motor to work properly. Many are able to run the code with no issues, but I get the following error. [Argument 3] should be within aSequence, but not sure why it is not picking it up. Any advice on how to fix it would be appreciated.
Traceback (most recent call last):
if sys.argv[3] == "cw":
IndexError: list index out of range
Code
import sys
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
aMotorPins = [12, 15, 11, 13]
for pin in aMotorPins:
GPIO.setup(pin,GPIO.OUT)
GPIO.output(pin, False)
aSequence = [
[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]
]
iNumSteps = len(aSequence)
if sys.argv[3] == "cw":
iDirection = 1
else:
iDirection = -1
fWaitTime = int(sys.argv[1]) / float(1000)
iDeg = int(int(sys.argv[2]) * 11.377777777777)
iSeqPos = 0
if len(sys.argv) > 4:
iSeqPos = int(sys.argv[4])
Thank you for your help