Difference between revisions of "The code to control a stepper motor"
From MyWiki
(Created page with "<source lang="python"> import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) control_pins = [7,11,13,15] for pin in control_pins: GPIO.setup(pin, GPIO.OUT) GP...") |
|||
Line 1: | Line 1: | ||
+ | https://medium.com/@Keithweaver_/controlling-stepper-motors-using-python-with-a-raspberry-pi-b3fbd482f886 | ||
+ | |||
<source lang="python"> | <source lang="python"> | ||
import RPi.GPIO as GPIO | import RPi.GPIO as GPIO |
Latest revision as of 21:08, 28 April 2020
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) control_pins = [7,11,13,15] for pin in control_pins: GPIO.setup(pin, GPIO.OUT) GPIO.output(pin, 0) halfstep_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(512): for halfstep in range(8): for pin in range(4): GPIO.output(control_pins[pin], halfstep_seq[halfstep][pin]) time.sleep(0.001) GPIO.cleanup()