LCD screen control by I2C protocol with Raspberry Pi Pico

The following program can control an LCD screen through an I2C protocol connected to Raspberry Pi Pico. The serial data(SDA) pin is connected to Pin 0 and the serial clock (SCL) pin is connected to Pin 1 of Pico. The LCD screen takes 5V.

Please remember that we need two I2C libraries. You can download that library from https://github.com/T-622/RPI-PICO-I2C-LCD. Upload the lcd_api.py and pico_i2c_lcd.py to your Pico before running the following code.

import utime

import machine
from machine import I2C
from lcd_api import LcdApi
from pico_i2c_lcd import I2cLcd

I2C_ADDR     = 0x27
I2C_NUM_ROWS = 2
I2C_NUM_COLS = 16

i2c = I2C(0, sda=machine.Pin(0), scl=machine.Pin(1), freq=400000)
lcd = I2cLcd(i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS) 

lcd.clear()
lcd.move_to(14,0)
lcd.putstr("It Works")