import RPi.GPIO as GPIO # Import library for GPIO (pin) access GPIO.setmode(GPIO.BOARD) # Specify that we use the BOARD numbers (pin numbers 1-26 on the connector) GPIO.setwarnings(False) # Disable the warning "This channel is already in use" import time # **** PIN CONFIGURATIONS ********************************** GPIO.setup(22, GPIO.IN) # Configure pin 22 as input (IN) GPIO.setup(24, GPIO.IN) # Configure pin 24 as input (IN) GPIO.setup(19, GPIO.OUT) # Configure pin 19 as output (OUT) # ********************************************************** GPIO.output(19, 0) # turn off the LED when the program starts while True: s0 = GPIO.input(22) # read switch 0 s1 = GPIO.input(24) # read switch 1 if s0 == 0: # if switch 0 is pressed... GPIO.output(19, 0) # ...turn off the LED elif s1 == 0: # if switch 1 is pressed... GPIO.output(19, 1) # ...turn on the LED time.sleep(0.01) # wait 10ms before checking the switches again