from machine import Pin, I2C
from time import sleep
import ssd1306
button1 = Pin(15, Pin.IN, Pin.PULL_DOWN)
button2 = Pin(2, Pin.IN, Pin.PULL_DOWN)
led = Pin(12, Pin.OUT)
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
def update_oled(status):
oled.fill(0)
oled.text("LED Status:", 0, 0)
oled.text(status, 0, 10)
oled.show()
def debug():
print("Button 1:", button1.value())
print("Button 2:", button2.value())
print("LED is on:", led.value())
while True:
button1_state = button1.value()
button2_state = button2.value()
if button1_state == 1:
led.on()
update_oled("ON")
print("LED ON")
if button2_state == 1:
led.off()
update_oled("OFF")
print("LED OFF")
debug()
sleep(0.1)