Site Guide

Find your way around the Engineering Club.

Know what you need? Search for a component, concept or project.

Around the site

Start

Labs

TestingExperimental

Build

Club

LearnExperimental

Go a little deeper

Entry points to larger collections. Use Search for individual records.

Learning paths & reference

Inside PiCrawlerExperimental

Inside Inventory

LCD Hello World / Stage 3 of 3

Stable page updates

Alternate complete fixed-width messages without repeated clear.

Compiled 2026-10-19 (historical) · electrical review required

Download stage 3 PlatformIO projectRead code & run steps ↓

What changes now?

Alternate complete fixed-width messages without repeated clear.

Expected after hardware review: Long and short messages leave no stale trailing characters.

Builds on stage 2: Changing values.

What you need

Check availability and exact module markings before starting.

Connections / current hardware gate

Before connecting power. The LCD backpack supply and pull-up rail are unresolved. Confirm its expander and pin mapping before powering it; the program stops until electrical review is complete.

  • Read the backpack IC marking and confirm compatibility with hd44780_I2Cexp.
  • Verify VCC, ground and the SDA/SCL pull-up rail. The conditional Mega reference uses D20/SDA and D21/SCL; it does not approve a supply voltage.
  • Keep kElectricalReviewComplete false until the actual wiring and power review is recorded.
Conditional connection table and full module facts

Electrical review is incomplete. Conditional references require confirmation; unresolved pins or rails are not wiring instructions. Power off before changing connections.

From device / pinTo device / pinSignal / voltageConnection status and notes
LCD1602 16×2 Character Display with I²C Backpack
SDA
ELEGOO Mega 2560 R3 board
D20 / SDA
I2C SDA
Voltage unresolved
Conditional reference

Verify backpack IC, carrier supply and pull-up rail before enabling.

LCD1602 16×2 Character Display with I²C Backpack
SCL
ELEGOO Mega 2560 R3 board
D21 / SCL
I2C SCL
Voltage unresolved
Conditional reference

Mega mapping; not Uno A4/A5.

display/peripheral
GND
controller
GND
Signal reference
0 V
Conditional reference

Unpowered wiring check; use correct common-ground topology and keep high-current panel returns out of thin signal paths.

display/peripheral
VCC
verified supply
Pin unresolved
Peripheral power
Voltage unresolved
Conditional reference

Supply voltage/current unknown at carrier level until reviewed; no assumed 5 V or 3.3 V instruction.

Access describes the source of a requirement. Check availability, the exact revision and the complete power/driver/harness system before starting. Inventory quantities are expected purchase/BOM quantities, not live stock.

Use this complete project

Target: megaatmega2560 · Environment: checkpoint3 · Stage branch: DISPLAY_STAGE=3

  1. Open the complete project. Download the stage ZIP, extract it and open the folder containing platformio.ini and src in VS Code. Keep its supporting headers and libraries together.
  2. Build stage 3. Select checkpoint3 in PlatformIO Project Tasks → General → Build, or use a PlatformIO terminal:
    pio run -e checkpoint3
    A successful Build compiles the program; it does not upload it or approve electrical connections.
  3. Stop at the hardware gate. The supplied electrical-review flag remains false. Have a qualified reviewer complete the actual module, wiring and power checks before using an approved configuration for hardware operation.

    As supplied, Serial at 115200 baud reports STOP: complete wiring/power review in guide before enabling hardware. and initialization stops.

After electrical review: Upload and Monitor

Only with the actual setup reviewed and the configuration explicitly approved, choose this stage's Upload task. Close any monitor using the board first.

pio run -e checkpoint3 -t upload

Open the matching Monitor at 115200 baud, then compare the expected result with what actually happens.

pio device monitor -b 115200

Record Build, Upload and physical observations separately.

Complete source

The viewer starts at src/main.cpp. Use Source file for the board profile, PlatformIO configuration and supporting code. Keep the complete ZIP together.

workspaces/lcd-hello-world/src/main.cpp

main.cpp
#include <Arduino.h>
#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h>
#include <DisplayCore.h>
#include "board_profile.h"
hd44780_I2Cexp lcd;
bool ready=false;
uint32_t lastUpdate=0;
void row(uint8_t r,const char* text){lcd.setCursor(0,r);char padded[17];uint8_t i=0;for(;i<16&&text[i];++i)padded[i]=text[i];for(;i<16;++i)padded[i]=' ';padded[16]='\0';lcd.print(padded);}
void setup(){Serial.begin(115200); if(!kElectricalReviewComplete){Serial.println("STOP: complete wiring/power review in guide before enabling hardware.");return;}Wire.begin();const int status=lcd.begin(16,2);if(status){Serial.print("LCD initialization error: ");Serial.println(status);return;}ready=true;}

 void loop(){if(!ready)return;const uint32_t now=millis();
 if(!displaylab::elapsed(now,lastUpdate,1000))return;lastUpdate=now;
 row(0,"Engineering Club");
 #if DISPLAY_STAGE == 1
 row(1,"Hello, LCD");
 #elif DISPLAY_STAGE == 2
 char line[17];snprintf(line,sizeof(line),"Seconds:%lu",(unsigned long)(now/1000));row(1,line);
 #else
 const bool page=((now/3000)%2)!=0;row(1,page?"16 cols, 2 rows":"No clear flicker");
 #endif
 }
Source integrity · SHA-2563848f848671ff0237ba4ff9c96068793b8ccd6ba8493032b166a18ca8ec1fa91

Raw downloads and standalone ZIPs retain the canonical bytes and supporting files. Copy follows the selected Comments setting.

Check the result

Long and short messages leave no stale trailing characters.

As supplied, the false electrical-review flag prevents this hardware result. After qualified review, record what actually happens; the text above is an expected result, not a bench transcript.

Original verification checklist
  1. Build the exact selected environment; distinguish dependency resolution from source compilation.
  2. Observe the stated output and record actual behavior; expected result is not an observed transcript.
  3. Test the named failure mode before proceeding.

Troubleshooting

Backlight, no text

Check the contrast adjustment and startup Serial status separately. A lit backlight proves neither bus traffic nor LCD initialization. Run the I²C diagnostic before changing application formatting.

Library cannot initialize

Record the error code, scan address and backpack IC marking. A successful ACK with unsupported expander mapping still cannot establish a working LCD.

Old characters remain

Confirm the fixed-width row helper is used rather than printing a shorter replacement onto existing characters. Check the zero-based row selection and sixteen-cell limit.

Technical explanation / original guide

Read the complete original stage guide

Original source/research wording is preserved. The stage's dated build evidence above supersedes earlier blanket compile-status wording; no physical results are implied.

Build it

Alternate complete fixed-width messages without repeated clear.

Open workspaces/lcd-hello-world in VS Code/PlatformIO. Select checkpoint3 and run pio run -e checkpoint3. This is FIRMWARE_SOURCE_AUTHORED with embedded compilation unverified. Review the electrical flag and canonical conditional wiring before any upload.

Understand it

The chosen hd44780_I2Cexp class can discover compatible PCF8574/MCP23008 backpack address and mapping, and begin returns a status. That avoids hard-coding 0x27 from an unrelated tutorial. It cannot make an arbitrary expander compatible. The object declaration creates library-managed state; setup configures communication once; loop revisits time-driven work. The row helper copies at most sixteen characters into a seventeen-byte buffer and appends a terminator. It then pads the remaining cells with spaces, replacing the old visible row without a clear-screen flash.

Expected result and verification

Long and short messages leave no stale trailing characters.

This is expected after a correct build and electrical review, not a captured bench transcript.

Check the selected source branch and named failure conditions. Record actual build or software output separately from future physical observations.

Likely failures

Backlight, no text: Check the contrast adjustment and startup Serial status separately. A lit backlight proves neither bus traffic nor LCD initialization. Run the I²C diagnostic before changing application formatting.

Library cannot initialize: Record the error code, scan address and backpack IC marking. A successful ACK with unsupported expander mapping still cannot establish a working LCD.

Old characters remain: Confirm the fixed-width row helper is used rather than printing a shorter replacement onto existing characters. Check the zero-based row selection and sixteen-cell limit.

Build evidence, target and remaining verification

Original status: unverified.

Successful checkpoint3 build recorded 2026-10-19 for megaatmega2560; 5 warnings recorded.

No compile was attempted in this pass under the user's testing limit. Upload and physical bench observation remain untested.

atmelavr@5.1.0 · arduino

Diagnostics before integration