Skip to content

Instantly share code, notes, and snippets.

@punkyoon
Created June 9, 2018 13:19
Show Gist options
  • Select an option

  • Save punkyoon/a5c3d0e1d9b9982225f7a0c13bb617da to your computer and use it in GitHub Desktop.

Select an option

Save punkyoon/a5c3d0e1d9b9982225f7a0c13bb617da to your computer and use it in GitHub Desktop.
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(27, GPIO.OUT)
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
print('Press the button')
try:
while True:
input_state = GPIO.input(23)
if input_state == False:
GPIO.output(27, GPIO.HIGH)
else:
GPIO.output(27, GPIO.LOW)
time.sleep(1)
except KeyboardInterrupt:
GPIO.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment