Display Class

🖥️ LCD 1602 (I2C Module)

📌 Description

The LCD 1602 is a display module that can show text. With the I2C adapter, it only needs two pins (SDA and SCL) to communicate, making it easier to connect. It can display up to 16 characters per line and has 2 lines.

🎯 Use

In our projects, the LCD 1602 is used to:

  • Show messages, numbers, or sensor readings.
  • Display robot status (like “Ready”, “Obstacle detected”).
  • Make the robot more interactive by showing information instead of only lights or sounds.

👉 Think of the LCD as the robot’s screen — it shows what the robot wants to say.

Module parameters

Pin name Description
GND GND (Power Input Negative)
VCC VCC (Power Input Cathode)
SDA Bidirectional data communication pins
SCL Clock signal communication pin
  • Supply voltage: 3.3V/5V
  • Connection: PH2.0 4P terminal
  • Installation method: screw fixing

🖥️ Code Explanation

import machine
import i2clcd

# Configure I2C communication
i2c_extend = machine.SoftI2C(scl = machine.Pin(22), sda = machine.Pin(21), freq = 100000)

# Initialize LCD with 16 columns, address 0x27
lcd = i2clcd.LCD(i2c_extend, lcd_width=16, i2c_addr=0x27)

# Show text on the first line, centered
lcd.shows('Clu-Bots', column=0, line=0, center=True)

Step by Step

  1. import machine, i2clcd → Tools for pins and LCD control.
  2. i2c_extend = machine.SoftI2C(...) → Sets up I2C communication using pins 22 (SCL) and 21 (SDA).
  3. lcd = i2clcd.LCD(...) → Initializes the LCD with 16 characters per line and address 0x27.
  4. lcd.shows('Clu-Bots', ...) → Displays the text “Clu-Bots” on line 0 (first line), centered.

👉 Together, this program makes the LCD show the word Clu‑Bots on its screen.


✅ Conclusion of the Test

  • If the LCD shows “Clu‑Bots” on the first line, the program is working correctly.
  • This test shows how the robot can send text to a screen.
  • Later, you can display sensor values, menus, or even scrolling text to make the robot more interactive.
On this page