Last active
December 22, 2015 09:59
-
-
Save theapi/6455725 to your computer and use it in GitHub Desktop.
Very basic script that rotates a stepper motor with a Raspberry Pi.
This file contains 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 characters
#!/usr/bin/env python | |
# Thanks to http://www.youtube.com/watch?v=Dc16mKFA7Fo | |
import time | |
import RPi.GPIO as GPIO | |
GPIO.setmode(GPIO.BOARD) | |
ControlPin = [18,22,24,26] | |
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], | |
[0,0,0,1], | |
[1,0,0,1] ] | |
for i in range(256): | |
for halfstep in range(8): | |
for pin in range(4): | |
GPIO.output(ControlPin[pin], seq[halfstep][pin]) | |
time.sleep(0.01) | |
time.sleep(2) | |
for i in range(256): | |
for halfstep in reversed(range(8)): | |
for pin in range(4): | |
GPIO.output(ControlPin[pin], seq[halfstep][pin]) | |
time.sleep(0.001) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment