from responses import responses as r
from random import choice
from machine import I2C, Pin
from time import sleep
from pico_i2c_lcd import I2cLcd
i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
I2C_ADDR = i2c.scan()[0]
lcd = I2cLcd(i2c, I2C_ADDR, 2, 16)
answer_btn = Pin(4, Pin.IN)
reset_btn = Pin(5, Pin.IN)
force_good = Pin(6, Pin.IN)
force_bad = Pin(7, Pin.IN)
force_nutral = Pin(8, Pin.IN)
lcd.putstr('What would you \nlike to know?')
while True:
if answer_btn.value():
sleep(0.1)
group = choice(r)
reply = choice(group)
lcd.clear()
lcd.putstr(reply)
if reset_btn.value():
sleep(0.1)
lcd.clear()
lcd.putstr('What would you \nlike to know?')
if force_good.value():
sleep(0.1)
lcd.clear()
group = r[0]
reply = choice(group)
lcd.putstr(reply)
if force_bad.value():
sleep(0.1)
lcd.clear()
group = r[1]
reply = choice(group)
lcd.putstr(reply)
if force_nutral.value():
sleep(0.1)
lcd.clear()
group = r[2]
reply = choice(group)
lcd.putstr(reply)