Skip to content

Instantly share code, notes, and snippets.

@Phasip
Created June 7, 2015 18:56
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 Phasip/3814635ba16c19c5f2af to your computer and use it in GitHub Desktop.
Save Phasip/3814635ba16c19c5f2af to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import time
import RPi.GPIO as GPIO
inpin = 11 #BCM17
GPIO.setmode(GPIO.BOARD)
GPIO.setup(inpin,GPIO.IN, pull_up_down=GPIO.PUD_UP)
def simple():
while True:
time.sleep(0.1)
curr = GPIO.input(inpin)
print(str(curr))
def event():
def myE(ch):
curr = GPIO.input(inpin)
print(str(curr))
GPIO.add_event_detect(inpin, GPIO.BOTH, callback=myE, bouncetime=300)
while True:
time.sleep(1)
try:
event()
finally:
GPIO.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment