So I am building a system that will dispense a treat if they push a button.
I am using this setup as a start to run a step motor, but run into issues when I run the code. Its probably a simply thing, but am not experienced enough to judge what it is.
This is the code:
Code: Select all
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) ControlPin = [7,11,13,15] for pin in ControlPin: GPIO.setup(pin,GPIO.OUT) GPIO.output(pin,0) seq = [ [1,0,0,0], [1,1,0,0], [0,1,0,0], [0,1,1,0], [0,0,1,0], [0,0,1,1], [1,0,0,1] ] for i in range(512): for halfstep in range(8): for pin in range(4): GPIO.output(ControlPin[pin], seq[halfstep][pin]) time.sleep(0.001) GPIO.cleanup()
And I get an error on line 23 saying the list index is out of range.
Do you guys have any suggestions on what the problem could be?
The code comes from this link : https://www.youtube.com/watch?v=Dc16mKFA7Fo&t=478s