Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. import time
  2. import RPi.GPIO
  3.  
  4. # Initializing the GPIO pins. The numbering using is board.
  5. RPi.GPIO.setmode(RPi.GPIO.BOARD)
  6.  
  7. # Configuring the GPIO pin number 8 to be an output pin.
  8. RPi.GPIO.setup(8, RPi.GPIO.OUT)
  9.  
  10. print("Running Motor.")
  11. # Running the motor by changing the GPIO output pin state to high.
  12. RPi.GPIO.output(8, RPi.GPIO.HIGH)
  13.  
  14. # Leave the motor running for 3 seconds.
  15. time.sleep(3)
  16.  
  17. # Stop the motor by changing the GPIO output pin state back to low.
  18. RPi.GPIO.output(8, RPi.GPIO.LOW)
  19.  
  20. # cleanup all GPIO pins.
  21. print("Clean Up GPIO.")
  22. RPi.GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement