from machine import Pin, I2C
from i2c_lcd import I2_cLcd
import time
# I2C Configuration
i2c = I2C(0, scl=Pin(21), sda=Pin(22), freq=400000)
# Scan I2C devices
devices = i2c.scan()
print("I2C Devices:", devices)
if len(devices) == 0:
print("No I2C device found!")
else:
lcd = I2cLcd(i2c, devices[0], 2, 16)
lcd.clear()
lcd.putstr("Hello, ESP32!")
while True:
lcd.move_to(0, 1)
lcd.putstr("MicroPython")
time.sleep(2)
lcd.clear()
lcd.putstr("LCD Working!")
time.sleep(2)
lcd.clear()