Skip to content

Instantly share code, notes, and snippets.

@anoochit
Last active August 29, 2015 14:07
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 anoochit/1158cdfaca69998187da to your computer and use it in GitHub Desktop.
Save anoochit/1158cdfaca69998187da to your computer and use it in GitHub Desktop.
raspberry pi button and led with gpio
#!/usr/bin/env python
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(17,GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(27,GPIO.OUT)
GPIO.output(27,GPIO.LOW)
while True:
state = GPIO.input(17)
if state == False:
print('Button Pressed')
GPIO.output(27,GPIO.HIGH)
time.sleep(0.2)
GPIO.output(27,GPIO.LOW)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment