How to Display Text on a 16×2 LCD with Raspberry Pi Pico on Wokwi
Interface a 16×2 character LCD (HD44780) with Raspberry Pi Pico using 4-bit parallel
mode — no hardware needed, entirely in Wokwi. Includes full
diagram.json,
complete wiring tables, Arduino C++ code with the LiquidCrystal library, and a live simulation link.
What This Project Demonstrates
The HD44780-compatible 16×2 LCD is one of the most widely used displays in embedded systems — found in coffee machines, industrial panels, and DIY electronics. This tutorial drives it from a Raspberry Pi Pico using 4-bit parallel mode, reducing required GPIO pins from 11 down to just 6.
Understanding the 16×2 LCD Display
The 16×2 LCD has 2 rows and 16 character columns — 32 total character positions. It uses the HD44780 controller, which is natively supported by Arduino's built-in LiquidCrystal library. The display has 16 pins.
Row 1: "Hello World!" at position (col 0, row 0) · Row 2: "> Pi Pico <" at position (col 2, row 1)
All 16 LCD Pins Explained
| Pin | Symbol | Function | Description |
|---|---|---|---|
| 1 | VSS | Ground | Power ground (0V) |
| 2 | VDD | Power | +3.3V or +5V supply |
| 3 | V0 / VEE | Contrast | Contrast voltage via potentiometer |
| 4 | RS | Register Select | LOW = command, HIGH = data |
| 5 | RW | Read / Write | LOW = write — always ground for write-only use |
| 6 | E | Enable | Rising edge triggers read/write |
| 7–10 | D0–D3 | Data (low nibble) | Not used in 4-bit mode |
| 11 | D4 | Data bit 4 | 4-bit bus, bit 0 |
| 12 | D5 | Data bit 5 | 4-bit bus, bit 1 |
| 13 | D6 | Data bit 6 | 4-bit bus, bit 2 |
| 14 | D7 | Data bit 7 | 4-bit bus, bit 3 |
| 15 | A / LED+ | Backlight + | Backlight anode (via 220Ω resistor) |
| 16 | K / LED− | Backlight − | Backlight cathode (GND) |
4-bit vs 8-bit Mode
8-bit Mode
Uses all 8 data pins (D0–D7). Faster transfers but needs 11 GPIO pins total — not practical on most projects.
4-bit Mode Used Here
Uses only D4–D7, sending data in two nibbles. Saves 4 GPIO pins with negligible speed difference.
Step-by-Step Wokwi Setup
-
1
Create a New Raspberry Pi Pico Project
Open wokwi.com, click "New Project" and select "Raspberry Pi Pico". This tutorial uses the Arduino/C++ environment, which is activated automatically via the
env: arduino-communityattribute in the diagram.json below. -
2
Add the 16×2 LCD Display
Click the blue "+" button, search for "LCD 16x2" or "LCD1602", and place it above the Pico. The LCD in Wokwi is pre-configured with the HD44780 controller — no additional setup needed.
-
3
Add a 220Ω Resistor for the Backlight
Click "+", search for "Resistor", add it, and set its value to
220in the attributes panel. This protects the LED backlight from excess current.💡If you skip the potentiometer, connect LCD Pin 3 (V0) directly to GND for maximum contrast. In the diagram.json below, Wokwi handles contrast automatically.
-
4
Wire Power, Ground and RW
LCD Pin Name Pico Pin Wire Color 1 VSS — GND GND.1 Black 2 VDD — Power VSYS Red 5 RW — Read/Write GND.1 Black 15 A / LED+ 220Ω → VSYS Pink 16 K / LED− GND.1 Black ⚠️Always ground RW. Leaving it floating causes erratic LCD behavior. Since we only write to the display, permanently grounding RW is the correct approach.
-
5
Wire the Control Pins (RS and E)
LCD Pin Symbol Pico GPIO Wire Color Purpose 4 RS GP12 Blue Register Select — data vs command 6 E GP11 Purple Enable — clocks data into LCD -
6
Wire the 4-bit Data Bus (D4–D7 only)
D0–D3 are left unconnected in 4-bit mode.
LCD Pin Symbol Pico GPIO Wire Color 11 D4 GP10 Green 12 D5 GP9 Brown 13 D6 GP8 Gold 14 D7 GP7 Gray ✅LiquidCrystal constructor order:
LiquidCrystal lcd(12, 11, 10, 9, 8, 7)maps to RS, E, D4, D5, D6, D7. The order must exactly match your GPIO connections. -
7
GPIO Pin Summary
All 6 GPIO connections at a glance:
GP12RSGP11E (Enable)GP10D4GP9D5GP8D6GP7D7 -
8
Run the Simulation
Paste the code below into the Wokwi code editor, then press ▶ Play. The LCD will show "Hello World!" on row 1 and "> Pi Pico <" offset on row 2 — immediately.
diagram.json — Complete Circuit
Paste this into the diagram.json tab in Wokwi to instantly load the full wired circuit — Pico rotated 90°, LCD1602, and 220Ω backlight resistor, all pre-connected.
{
"version": 1,
"author": "Uri Shaked",
"editor": "wokwi",
"parts": [
{
"type": "wokwi-pi-pico",
"id": "pico",
"top": 123.67,
"left": 135.97,
"rotate": 90,
"hide": false,
"attrs": { "env": "arduino-community" }
},
{
"type": "wokwi-lcd1602",
"id": "lcd",
"top": -17.85,
"left": 22.03,
"rotate": 0,
"hide": false,
"attrs": {}
},
{
"type": "wokwi-resistor",
"id": "r1",
"top": 114.8,
"left": 226.31,
"rotate": 0,
"hide": false,
"attrs": { "value": "220" }
}
],
"connections": [
// ── Power & ground ──────────────────────
[ "pico:GND.1", "lcd:VSS", "black",
[ "v-51", "*", "h0", "v18" ] ],
[ "pico:GND.1", "lcd:K", "black",
[ "v-51", "*", "h0", "v18" ] ],
[ "pico:GND.1", "lcd:RW", "black",
[ "v-51", "*", "h0", "v18" ] ],
[ "pico:VSYS", "lcd:VDD", "red",
[ "v16", "h-16" ] ],
// ── Backlight via 220Ω resistor ──────────
[ "pico:VSYS", "r1:2", "red", [ "v16", "h0" ] ],
[ "r1:1", "lcd:A", "pink", [] ],
// ── Control signals ──────────────────────
[ "pico:GP12", "lcd:RS", "blue",
[ "v-16", "*", "h0", "v20" ] ],
[ "pico:GP11", "lcd:E", "purple",
[ "v-20", "*", "h0", "v20" ] ],
// ── 4-bit data bus ───────────────────────
[ "pico:GP10", "lcd:D4", "green",
[ "v-24", "*", "h0", "v20" ] ],
[ "pico:GP9", "lcd:D5", "brown",
[ "v-28", "*", "h0", "v20" ] ],
[ "pico:GP8", "lcd:D6", "gold",
[ "v-32", "*", "h0", "v20" ] ],
[ "pico:GP7", "lcd:D7", "gray",
[ "v-36", "*", "h0", "v20" ] ]
]
}
How to use: In Wokwi, click the diagram.json tab, select all text, and paste. The complete circuit loads instantly — no manual wiring needed.
Arduino C++ — LCD Display Program
Uses Arduino's built-in LiquidCrystal library — no extra installation
required. Constructor: LiquidCrystal(RS, E, D4, D5, D6, D7).
// 16x2 LCD Display with Raspberry Pi Pico // MakeMindz.com — Project 5 of 20 // 4-bit parallel mode via LiquidCrystal library #include <LiquidCrystal.h> // Pins: RS=GP12, E=GP11, D4=GP10, D5=GP9, D6=GP8, D7=GP7 LiquidCrystal lcd(12, 11, 10, 9, 8, 7); void setup() { lcd.begin(16, 2); // 16 columns, 2 rows // Row 1 — cursor starts at (col 0, row 0) by default lcd.print("Hello World!"); // Row 2 — setCursor(column, row): 0-indexed lcd.setCursor(2, 1); // column 2, row 1 lcd.print("> Pi Pico <"); } void loop() { delay(1); // Improves Wokwi simulation speed }
setCursor(col, row): Columns are 0–15, rows are 0–1. setCursor(2, 1) places the cursor at the 3rd character of the 2nd row. Use this to precisely position any text.
Extend it: Add lcd.scrollDisplayLeft() inside loop() with a 300ms delay for a scrolling ticker effect!
All 20 Raspberry Pi Pico Projects
This tutorial is part of a complete series. Work through them progressively — beginner to advanced.
Comments
Post a Comment