#Lab31_LCD_Display.py
# Lib: https://peppe8o.com/download/micropython/LCD/lcd_api.py
# Lib: https://peppe8o.com/download/micropython/LCD/i2c_lcd.py
from machine import Pin, SoftI2C
from lcd_api import LcdApi
from i2c_lcd import I2cLcd
import time
sdaPIN= Pin(21) #for ESP32
sclPIN= Pin(22)
i2c= SoftI2C(sda=sdaPIN, scl=sclPIN, freq=100000)
# Check address i2c
devices = i2c.scan()
if len(devices) == 0:
print("No i2c device ")
else:
print('i2c devices found:',len(devices))
for device in devices:
print("At address: ", hex(device))
#
I2C_ADDR = 0x27
print(I2C_ADDR)
# Size display
totalRows = 2
totalColumns = 16
lcd = I2cLcd(i2c, I2C_ADDR, totalRows, totalColumns)
while True:
lcd.putstr("I2C LCD Tutorial")
lcd.putstr("ESP32micropython")
time.sleep(2)
lcd.clear()
lcd.putstr("Lets Count 0-10!")
lcd.clear()
for i in range(11):
lcd.putstr(str(i))
time.sleep(1)
lcd.clear()
time.sleep(2)
lcd.clear()