Advertisement
Guest User

stappenmotor

a guest
Nov 28th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. import RPi.GPIO as GPIO
  2. import time
  3. GPIO.setmode(GPIO.BCM)
  4.  
  5. pin1 = 24
  6. pin2 = 25
  7. pin3 = 8
  8. pin4 = 7
  9.  
  10. GPIO.setup(pin1, GPIO.OUT)
  11. GPIO.setup(pin2, GPIO.OUT)
  12. GPIO.setup(pin3, GPIO.OUT)
  13. GPIO.setup(pin4, GPIO.OUT)
  14.  
  15. def setStep(w1, w2, w3, w4):
  16.     GPIO.output(pin1, w1)
  17.     GPIO.output(pin2, w2)
  18.     GPIO.output(pin3, w3)
  19.     GPIO.output(pin4, w4)
  20.  
  21. while True:
  22.     delay = 0.002
  23.     setStep(1, 1, 0, 0)
  24.     time.sleep(delay)
  25.     setStep(0, 1, 1, 0)
  26.     time.sleep(delay)
  27.     setStep(0, 0, 1, 1)
  28.     time.sleep(delay)
  29.     setStep(1, 0, 0, 1)
  30.     time.sleep(delay)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement