import time
time.sleep(0.1) # Wait for USB to become ready
print("Hello, Pi Pico!")
from machine import Pin, I2C
from time import sleep
from i2c_lcd import I2cLcd # Ensure i2c_lcd.py is in the same folder
# Setup I2C for LCD
I2C_ADDR = 0x27 # Replace with your LCD's I2C address if different
i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
lcd = I2cLcd(i2c, I2C_ADDR, 2, 16)
# Setup buttons
count_button = Pin(15, Pin.IN, Pin.PULL_DOWN)
reset_button = Pin(16, Pin.IN, Pin.PULL_DOWN)
# Initialize counter
counter = 0
# Function to update the LCD
def update_lcd():
lcd.clear()
lcd.putstr("Count: {}".format(counter))
# Main program
update_lcd() # Initial display
while True:
if count_button.value():
counter += 1
update_lcd()
sleep(0.3) # Debounce delay
if reset_button.value():
counter = 0
update_lcd()
sleep(0.3) # Debounce delay