In this tutorial, we will learn how to interface a 16×2 I2C LCD with the Raspberry Pi Pico using Micro-Python to display messages and control cursor positions.
Buy Basic Raspberry Pi Pico Kit
Note:
Make sure your LCD has an I2C backpack, and you know its I2C address (default is usually 0x27 or 0x3F).
Items Required:
- Raspberry Pi Pico – 1 Nos.
- 16×2 I2C LCD Module – 1 Nos.
- https://roboindia.com/product/jumper-wire-set-10-each/Jumper wires (M/M) – as needed
- Breadboard – 1 Nos. (optional)
- USB cable (micro USB B) – 1 Nos.
Connections:
- SDA (LCD) → GPIO 4 (Pico)
- SCL (LCD) → GPIO 5 (Pico)
- VCC → 3.3V(also can use 5 volts)
- GND → GND


Code:
from machine import Pin, SoftI2C
from pico_i2c_lcd import I2cLcd
from time import sleep
# Define the LCD I2C address and dimensions
I2C_ADDR = 0x3f
I2C_NUM_ROWS = 2
I2C_NUM_COLS = 16
# Initialize I2C and LCD objects
i2c = SoftI2C(sda=Pin(0), scl=Pin(1), freq=400000)
lcd = I2cLcd(i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS)
lcd.putstr("It's working :)")
sleep(4)
try:
while True:
# Clear the LCD
lcd.clear()
# Display two different messages on different lines
# By default, it will start at (0,0) if the display is empty
lcd.putstr("Hello World!")
sleep(2)
lcd.clear()
# Starting at the second line (0, 1)
lcd.move_to(0, 1)
lcd.putstr("Hello World!")
sleep(2)
except KeyboardInterrupt:
# Turn off the display
print("Keyboard interrupt")
lcd.backlight_off()
lcd.display_off()
Result:
The LCD will initially display “It’s working :)” for 4 seconds. Then, in a loop, it will display “Hello World!” on the first line, then on the second line, switching every 2 seconds. This demonstrates text display and cursor control on the I2C LCD.