Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from time import sleep
- import RPi.GPIO as GPIO
- DIR = 20 # Direction GPIO Pin
- STEP = 21 # Step GPIO Pin
- CW = 1 # Clockwise Rotation
- CCW = 0 # Counterclockwise Rotation
- SPR = 48 # Steps per Revolution (360 / 7.5)
- GPIO.setmode(GPIO.BCM)
- GPIO.setup(DIR, GPIO.OUT)
- GPIO.setup(STEP, GPIO.OUT)
- GPIO.output(DIR, CW)
- step_count = SPR
- delay = .0208
- for x in range(step_count):
- GPIO.output(STEP, GPIO.HIGH)
- sleep(delay)
- GPIO.output(STEP, GPIO.LOW)
- sleep(delay)
- sleep(.5)
- GPIO.output(DIR, CCW)
- for x in range(step_count):
- GPIO.output(STEP, GPIO.HIGH)
- sleep(delay)
- GPIO.output(STEP, GPIO.LOW)
- sleep(delay)
- GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement