Skip to content

Instantly share code, notes, and snippets.

@suminb
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suminb/c2f48010ed27d24cbb21 to your computer and use it in GitHub Desktop.
Save suminb/c2f48010ed27d24cbb21 to your computer and use it in GitHub Desktop.
Controlling Raspberry Pi's GPIO with Python
import RPi.GPIO as GPIO
import time
PIN = 3
INTERVAL = 1.0
def main():
GPIO.setmode(GPIO.BOARD)
GPIO.setup(PIN, GPIO.OUT)
while True:
GPIO.output(PIN, 1)
time.sleep(INTERVAL)
GPIO.output(PIN, 0)
time.sleep(INTERVAL)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
GPIO.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment