Guest User

Untitled

a guest
Jul 18th, 2019
63
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from time import sleep
  2. import RPi.GPIO as GPIO
  3.  
  4. DIR = 20 # Direction GPIO Pin
  5. STEP = 21 # Step GPIO Pin
  6. CW = 1 # Clockwise Rotation
  7. CCW = 0 # Counterclockwise Rotation
  8. SPR = 48 # Steps per Revolution (360 / 7.5)
  9.  
  10. GPIO.setmode(GPIO.BCM)
  11. GPIO.setup(DIR, GPIO.OUT)
  12. GPIO.setup(STEP, GPIO.OUT)
  13. GPIO.output(DIR, CW)
  14.  
  15. step_count = SPR
  16. delay = .0208
  17.  
  18. for x in range(step_count):
  19. GPIO.output(STEP, GPIO.HIGH)
  20. sleep(delay)
  21. GPIO.output(STEP, GPIO.LOW)
  22. sleep(delay)
  23.  
  24. sleep(.5)
  25. GPIO.output(DIR, CCW)
  26. for x in range(step_count):
  27. GPIO.output(STEP, GPIO.HIGH)
  28. sleep(delay)
  29. GPIO.output(STEP, GPIO.LOW)
  30. sleep(delay)
  31.  
  32. GPIO.cleanup()
RAW Paste Data