Skip to content

Instantly share code, notes, and snippets.

@Indavelopers
Last active June 5, 2017 13:30
Show Gist options
  • Save Indavelopers/57802f2f2f776b9072b1e1f547dfb02b to your computer and use it in GitHub Desktop.
Save Indavelopers/57802f2f2f776b9072b1e1f547dfb02b to your computer and use it in GitHub Desktop.
Test de botones
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
PIN_BUTTON = 16
GPIO.setup(PIN_BUTTON, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
try:
while True:
time.sleep(0.05)
if GPIO.input(PIN_BUTTON):
print('Button is pushed')
except KeyboardInterrupt:
print('Script execution interrupted')
finally:
GPIO.cleanup()
print('Exiting execution: cleanning GPIO setup')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment