Skip to content

Instantly share code, notes, and snippets.

@brennen
Created June 5, 2015 20:37
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 brennen/be88bf813d751a680fbd to your computer and use it in GitHub Desktop.
Save brennen/be88bf813d751a680fbd to your computer and use it in GitHub Desktop.
switch
pi@raspberrypi ~ $ cat switch.py
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
input_state = GPIO.input(23)
if input_state == False:
print('Button Pressed')
time.sleep(0.2)
pi@raspberrypi ~ $ sudo python switch.py
Button Pressed
Button Pressed
Button Pressed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment