Created
June 5, 2015 20:37
-
-
Save brennen/be88bf813d751a680fbd to your computer and use it in GitHub Desktop.
switch
This file contains 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
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