This project configured a push button that turns on the LED when you push it.

# basic_i2c_configuration

import RPi.GPIO as GPIO import time from smbus import SMBus

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.cleanup()
bus = SMBus(1) # indicates /dev/ic2-1

button1=23
LED1=24
GPIO.setup(button1,GPIO.IN,pull_up_down=GPIO.PUD_UP) # Make button1 an input, Activate Pull UP Resistor
GPIO.setup(LED1,GPIO.OUT,) # Make LED 1 an Output
button_state = 1
GPIO.output(LED1,False)
while True:
button_state = GPIO.input(button1)
if button_state == 0:
GPIO.output(LED1,GPIO.HIGH)
else:
GPIO.output(LED1,GPIO.LOW)
time.sleep(1)

GPIO.cleanup()