Skip to content

Instantly share code, notes, and snippets.

@ahmedfgad
Created April 10, 2019 22:11
Show Gist options
  • Select an option

  • Save ahmedfgad/ba76a171ca5a96cc9f0561e2ea23f54b to your computer and use it in GitHub Desktop.

Select an option

Save ahmedfgad/ba76a171ca5a96cc9f0561e2ea23f54b to your computer and use it in GitHub Desktop.
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