Skip to content

Instantly share code, notes, and snippets.

@iotguider
Created September 4, 2017 11:05
Show Gist options
  • Save iotguider/ebc08b439e3be8ca6d6f01081dfee199 to your computer and use it in GitHub Desktop.
Save iotguider/ebc08b439e3be8ca6d6f01081dfee199 to your computer and use it in GitHub Desktop.
Code for LED with Pushbutton in Raspberry Pi
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(23,GPIO.IN)
GPIO.setup(18,GPIO.OUT)
while True:
inputval = GPIO.input(23)
if(inputval==True):
GPIO.output(18, GPIO.HIGH)
time.sleep(0.1)
GPIO.output(18,GPIO.LOW)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment