sw

 import RPi.GPIO as GPIO

import time 


GPIO.setwarnings(False)

GPIO.setmode(GPIO.BCM)

LEDPIN=24

SWITCHPIN=23

GPIO.setup(LEDPIN,GPIO.OUT)

GPIO.setup(SWITCHPIN,GPIO.IN)


while 1:

    SW = GPIO.input(SWITCHPIN)

    

    if SW == True:

        GPIO.output(LEDPIN,1)

        time.sleep(0.01)

    else:

        GPIO.output(LEDPIN,0)

        time.sleep(0.01)

    






Next Post Previous Post
No Comment
Add Comment
comment url