Created
June 9, 2018 13:19
-
-
Save punkyoon/a5c3d0e1d9b9982225f7a0c13bb617da to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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