Created
April 10, 2019 22:11
-
-
Save ahmedfgad/ba76a171ca5a96cc9f0561e2ea23f54b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| import RPi.GPIO | |
| # Initializing the GPIO pins. The numbering using is board. | |
| RPi.GPIO.setmode(RPi.GPIO.BOARD) | |
| # Configuring the GPIO pin number 8 to be an output pin. | |
| RPi.GPIO.setup(8, RPi.GPIO.OUT) | |
| print("Running Motor.") | |
| # Running the motor by changing the GPIO output pin state to high. | |
| RPi.GPIO.output(8, RPi.GPIO.HIGH) | |
| # Leave the motor running for 3 seconds. | |
| time.sleep(3) | |
| # Stop the motor by changing the GPIO output pin state back to low. | |
| RPi.GPIO.output(8, RPi.GPIO.LOW) | |
| # cleanup all GPIO pins. | |
| print("Clean Up GPIO.") | |
| RPi.GPIO.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment