from machine import I2C,Pin
from pico_i2c_lcd import I2cLcd
import time

# Configure I2C
i2c = I2C(1, sda=Pin(6), scl=Pin(7), freq=400000)

# Scan and check if any devices are found
devices = i2c.scan()

if not devices:
    print("No I2C device found! Check your wiring and power.")
else:
    LCD_ADDR = devices[0]
    print(f"I2C device found at address: {hex(LCD_ADDR)}")
    # Initialize 16x2 LCD
    lcd = I2cLcd(i2c, LCD_ADDR, 2, 16)
    lcd.putstr("Hello, XIAO!")
