Guest User

Untitled

a guest
Jan 13th, 2022
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1.  
  2. #!/usr/bin/python
  3. # -*- coding: utf-8 -*-
  4.  
  5. # Simple example of the easydriver Python library.
  6. # Dave Finch 2013
  7.  
  8. import easydriver as ed
  9.  
  10.  
  11. # Direction of rotation is dependent on how the motor is connected.
  12. # If the motor runs the wrong way swap the values of cw and ccw.
  13. cw = True
  14. ccw = False
  15.  
  16. """
  17. Arguments to pass or set up after creating the instance.
  18.  
  19. Step GPIO pin number.
  20. Delay between step pulses in seconds.
  21. Direction GPIO pin number.
  22. Microstep 1 GPIO pin number.
  23. Microstep 2 GPIO pin number.
  24. Microstep 3 GPIO pin number.
  25. Sleep GPIO pin number.
  26. Enable GPIO pin number.
  27. Reset GPIO pin number.
  28. Name as a string.
  29. """
  30.  
  31. # Create an instance of the easydriver class.
  32. # Not using sleep, enable or reset in this example.
  33. stepper = ed.easydriver(18, 0.004, 23, 24, 17, 25)
  34.  
  35. # Set motor direction to clockwise.
  36. stepper.set_direction(ccw)
  37.  
  38. # Set the motor to run in 1/8 of a step per pulse.
  39. #stepper.step()
  40.  
  41. # Do some steps.
  42. for i in range(0,2000):
  43. stepper.step()
  44.  
  45. # Clean up (just calls GPIO.cleanup() function.)
  46. stepper.finish()
  47.  
Advertisement
Add Comment
Please, Sign In to add comment