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 Instrument Panel / Stage 1 of 3

Read A0

Read a potentiometer wiper as raw ADC counts and mirror to Serial.

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

Download stage 1 PlatformIO projectRead code & run steps ↓

What changes now?

Initial isolated observation

Expected after hardware review: Counts vary across the Mega’s 0..1023 range.

What you need

Check availability and exact module markings before starting.

Connections / current hardware gate

Before connecting power. Confirm the LCD backpack supply/pull-ups and the potentiometer connections before power. The nominal 5 V ADC reference is an estimate, not a measurement.

  • Complete the LCD backpack checks from Hello World.
  • Verify the potentiometer end rails and A0 wiper connection against the conditional wiring reference.
  • Compare any voltage estimate with a meter; leave the electrical-review gate closed until the physical checks are complete.
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.

10 kΩ potentiometer
wiper
ELEGOO Mega 2560 R3 board
A0
ADC
5 V
Conditional reference

Identify terminals; outer ends to reviewed Mega reference supply and ground; nominal estimate is not calibration.

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: checkpoint1 · Stage branch: DISPLAY_STAGE=1

  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 1. Select checkpoint1 in PlatformIO Project Tasks → General → Build, or use a PlatformIO terminal:
    pio run -e checkpoint1
    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 checkpoint1 -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-instrument-panel/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;uint32_t now=millis();if(!displaylab::elapsed(now,lastUpdate,250))return;lastUpdate=now;
 const int raw=analogRead(A0);Serial.println(raw);char line[17];
 #if DISPLAY_STAGE == 1
 row(0,"A0 raw ADC");snprintf(line,sizeof(line),"Count:%4d",raw);
 #elif DISPLAY_STAGE == 2
 row(0,"Pot position");snprintf(line,sizeof(line),"Scale:%3d %%",int((raw*100L+511)/1023));
 #else
 row(0,"A0 estimate");const unsigned millivolts=(uint32_t(raw)*5000U+511U)/1023U;snprintf(line,sizeof(line),"%u.%03u V",millivolts/1000,millivolts%1000);
 #endif
 row(1,line);}
Source integrity · SHA-2562a1ac9dd3b7c4e434162492220927ed95d420883e685206b8e3e56600b6ec293

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

Check the result

Counts vary across the Mega’s 0..1023 range.

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

Constant zero or full scale

Verify the wiper and outer terminals with resistance/continuity checks, then measure the wiper voltage without exceeding the ADC input rail.

Readout jitters

Compare the raw Serial counts first. Shorten connections and stabilize reference/ground before adding a filter that could hide the fault.

Estimate disagrees with meter

Measure the actual reference and compare endpoint behavior. Explain model assumptions before adjusting the display to look correct.

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

Read a potentiometer wiper as raw ADC counts and mirror to Serial.

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

Understand it

The raw count is captured once per update and reused for calculation, display and Serial evidence. Integer arithmetic promotes the product before multiplying by 5000, avoiding a narrow intermediate. The display samples at 250 ms, so it does not flicker or waste bus traffic. The LCD row helper keeps old digits from surviving when a new number is shorter. An instrument needs a raw observation path as well as a formatted presentation; otherwise formatting can conceal a sensor or wiring fault.

Source review precision: The screen heading is A0 estimate; the calculation uses a nominal 5000 mV reference. It does not print an approximation symbol on the numeric line. Compare the model with an actual meter reading before treating the result as measured volts.

Expected result and verification

Counts vary across the Mega’s 0..1023 range.

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

Constant zero or full scale: Verify the wiper and outer terminals with resistance/continuity checks, then measure the wiper voltage without exceeding the ADC input rail.

Readout jitters: Compare the raw Serial counts first. Shorten connections and stabilize reference/ground before adding a filter that could hide the fault.

Estimate disagrees with meter: Measure the actual reference and compare endpoint behavior. Explain model assumptions before adjusting the display to look correct.

Build evidence, target and remaining verification

Original status: unverified.

Successful checkpoint1 build recorded 2026-10-19 for megaatmega2560; 4 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