Sub topic 12
Fixing blank, garbled, or missing displays
This chapter assumes you can upload sketches, wire a breadboard, install libraries, and have already driven a 16x2 HD44780 LCD (parallel and I2C backpack) and an SSD1306 OLED. It gives you a repeatable way to find the fault when a display shows nothing, shows nonsense, or the sketch hangs.
Work from the bottom layer up
A display problem almost always sits in one of four layers. Check them in this order, because a fault in a lower layer hides everything above it.
- Power and ground: does the module get the right voltage and a shared ground?
- Signal wiring: are the data and control lines on the pins the sketch expects?
- Addressing and configuration: does the sketch talk to the right I2C address, with the right library and screen size?
- Software: does the code initialize the display, draw into it, and send it out?
Step 0: confirm the basics
Before you touch the code, check three physical facts.
- The module's supply voltage matches the pin you used. Most 16x2 LCDs and I2C backpacks want 5 V. Many small SSD1306 modules accept 3.3 V or 5 V, but some bare modules accept only 3.3 V. Read the silkscreen or the seller's datasheet.
- Ground from the display connects to the Arduino ground. A missing ground can still light a backlight through other paths, which makes it look as if power is fine.
- Each jumper is fully seated. Breadboard contacts wear out, and a loose jumper on SDA or E causes intermittent faults that disappear when you touch the wire.
Use a multimeter if you have one. Measure between the display's VCC and GND pins. You should read within about 5% of the supply voltage.
Blank character LCD
A 16x2 LCD can look dead in several different ways. Identify which one you have.
| What you see | Most likely cause | Fix |
|---|---|---|
| Nothing at all, no backlight | No power, or backlight pins A/K not connected | Check VCC, GND, and the backlight pins |
| Backlight on, no characters, no blocks | Contrast too low, or sketch never ran | Turn the contrast potentiometer |
| Backlight on, top row solid blocks | Display powered but not initialized | Check E, RS, and data wiring, then reset |
| Characters appear faintly | Contrast slightly off | Adjust the potentiometer or the V0 resistor divider |
| Random symbols | Wrong data pins or loose D4-D7 | Compare each wire against the constructor |
Contrast is the most common cause
On a parallel HD44780 module, pin V0 sets the contrast. If V0 floats or sits at the wrong voltage, the screen shows nothing even though everything else is correct. Wire a 10 kΩ potentiometer with its ends on 5 V and GND and its wiper on V0. Turn it slowly while the sketch runs. Near one end you see a row of solid blocks, and near the other you see nothing. The usable range sits between them.
On an I2C backpack, a small blue trimmer sits on the board. Turn it with a screwdriver. Backpacks ship with this trimmer at a random position, so a brand-new module often looks blank.
The solid-blocks clue
A top row of solid blocks with an empty second row is the normal power-on state of an HD44780 before initialization. It tells you the screen has power and contrast is acceptable. The controller has not received a valid setup sequence. In that case, check these:
- The constructor pin order matches your wiring.
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);means RS=12, E=11, D4=5, D5=4, D6=3, D7=2. - The RW pin is tied to GND. A floating RW pin can leave the controller in read mode.
lcd.begin(16, 2)runs insetup().
Swapped data lines
If text appears but looks wrong (for example, wrong letters or characters shifted), a pair of data wires is probably swapped. In 4-bit mode the display uses D4 to D7 only. Leave D0 to D3 unconnected. Trace every wire from the display pin to the Arduino pin listed in the constructor, one at a time.
I2C displays: wrong address or no response
With an I2C display, the most useful single test is the scanner sketch from earlier in this tutorial.
#include <Wire.h>
void setup() {
Serial.begin(9600);
Wire.begin();
for (byte address = 1; address < 127; address++) {
Wire.beginTransmission(address);
if (Wire.endTransmission() == 0) {
Serial.print("Device found at 0x");
Serial.println(address, HEX);
}
}
}
void loop() {}Open the Serial Monitor at 9600 baud and read the output. Three outcomes are possible.
- An address appears and matches your sketch. The bus is fine, so look at contrast, library, or code.
- An address appears but differs from your sketch. Change the address in the constructor or in
display.begin(). Typical values are 0x27 or 0x3F for LCD backpacks and 0x3C or 0x3D for SSD1306 modules. - Nothing appears. The bus has a physical fault.
When the scanner finds nothing
Work through the physical causes.
- SDA and SCL are on the wrong pins. On an Uno or Nano, SDA is A4 and SCL is A5. On a Mega, SDA is pin 20 and SCL is pin 21. On a Leonardo, they are the dedicated SDA and SCL pins. Boards differ, so check your board's pinout.
- SDA and SCL are swapped. This is easy to do because the labels are small.
- The module has no power or no common ground.
- A solder joint on the header is cold. Backpacks and OLED modules that come with loose header pins need soldering. Reflow the joints if you see dull, grainy solder.
- Pull-up resistors are missing or too weak. Most breakout modules include them. A bare chip does not.
- The wires are too long. I2C is meant for short runs. Wires longer than about 50 cm can corrupt the signal at the default 100 kHz speed.
If the scanner hangs and prints nothing at all, SDA or SCL may be shorted to ground, which holds the bus low. Disconnect the display and run the scanner again. If it finishes without a device, the display or its wiring caused the hang.
Two devices on one address
Two I2C devices with the same address cannot share a bus. The scanner shows one address for both and the display behaves unpredictably. Many backpacks have solder jumpers (A0, A1, A2) that change the address. SSD1306 modules often have a resistor you can move between two positions to choose 0x3C or 0x3D.
Blank or wrong OLED
An SSD1306 differs from the LCD in two ways that matter here. It has no contrast pot, and the sketch must call display() before anything appears.
Initialization fails and the sketch stops
The OLED sketch from this tutorial contains this guard:
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
for (;;) {} // display not found: stop here
}If the screen stays blank and nothing else runs, the loop above may be trapping you. Add a message so you can tell. This version reports the failure on the serial port.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 display(128, 64, &Wire, -1);
void setup() {
Serial.begin(9600);
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed or not found"));
for (;;) {}
}
Serial.println(F("SSD1306 ready"));
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.println(F("Hello, OLED"));
display.display();
}
void loop() {}The begin() call returns false for two different reasons: the display does not answer at that address, or the library could not allocate its frame buffer. The first points to wiring or address. The second points to memory, covered below.
Address 0x3C versus 0x3D
Some 128x64 modules answer at 0x3D, and some marked 0x78 on the board really use 0x3C. The 0x78 label is the 8-bit form of the 7-bit address 0x3C. Arduino's Wire library uses the 7-bit form, so write 0x3C in the sketch. Always confirm with the scanner instead of trusting the label.
Nothing appears, but `begin()` succeeds
If initialization works and the screen is still dark, check these in turn:
display.display()is called after drawing. The library draws into a buffer in RAM. Nothing reaches the glass untildisplay()runs.setTextColor(SSD1306_WHITE)is set. Without a color, the default may draw invisible text.- The coordinates are on screen. A cursor at y=70 on a 64-pixel display draws off the edge.
- The size passed to the constructor matches the panel. A 128x32 panel needs
Adafruit_SSD1306 display(128, 32, &Wire, -1);and a matchingbegin()height.
Half the screen or shifted lines
If you see a shifted or half-height picture, the constructor height is probably wrong for your panel. A 128x32 panel driven as 128x64 shows doubled or sliced content. Match the constructor to the physical panel.
Garbled output
Garbled means the display responds but shows the wrong thing. Compare these patterns to find the cause.
| Symptom | Likely cause |
|---|---|
| Random pixel noise on OLED | Loose SDA or SCL, long wires, or wrong panel size |
| Wrong characters on LCD | Swapped data lines, or the wrong library for the backpack |
| Text appears, then partly corrupts over time | Low RAM, stack overflow, or electrical noise |
| Old characters stay behind | The sketch never clears or overwrites them |
| Characters flicker | The sketch clears and redraws the LCD every pass |
Leftover characters
On an LCD, print() writes only the characters you give it. If a value shrinks from 100 to 99, the old last digit stays on the screen. Pad the output or overwrite with spaces. The cleanest fix is to print a fixed-width field.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.begin(16, 2);
}
void loop() {
int value = (millis() / 100) % 1000;
lcd.setCursor(0, 0);
lcd.print("Value: ");
lcd.print(value);
lcd.print(" "); // erase leftover digits
delay(100);
}Avoid lcd.clear() inside loop(). It takes about 1.5 ms and blanks the whole screen each time, which causes visible flicker. On an OLED, calling clearDisplay() then display() each frame works well because the whole buffer goes out at once.
Wrong library for the backpack
Several LiquidCrystal_I2C forks exist, and they use different method names. Some use init(), others use begin(). Some backpacks wire the PCF8574 chip to the LCD pins in a different order, and a library written for one order prints nonsense on another. If the address is right and the contrast is right but the text is wrong, try a different library fork before you rewire anything.
Memory trouble
The SSD1306 library keeps a full copy of the screen in RAM. A 128x64 monochrome panel needs 128 × 64 / 8 = 1024 bytes. A 128x32 panel needs 512 bytes. An Uno has 2048 bytes of RAM in total. After the buffer, the I2C library, and your own variables, little remains.
Signs of a RAM shortage:
begin()returns false because the allocation failed.- The sketch resets, or behaves oddly once you add more strings or arrays.
- The IDE warns that low memory may cause stability problems.
Check the compile output for "Global variables use N bytes". If it exceeds about 75% of dynamic memory, expect trouble. Wrap constant strings in F() so they stay in flash, as in display.println(F("Hello, OLED"));. Remove large char arrays and unused libraries.
A systematic test routine
When you can't see the problem, shrink the sketch until it is trivially small.
- Disconnect everything except the display, power, and ground.
- Run the I2C scanner or the plain "Hello, world!" LCD example.
- Change one thing at a time: the address, then a wire, then the library.
- Test the module on a second board if you have one. This separates a bad display from a bad setup.
- Keep notes. Write down each change and its result so you don't repeat tests.
Quick reference checklist
- Power: correct voltage, shared ground, seated wires.
- LCD contrast: turn the potentiometer or backpack trimmer.
- LCD pins: constructor order matches wiring, RW to GND.
- I2C pins: SDA and SCL on the correct pins for your board.
- Address: run the scanner, then copy the address into the sketch.
- OLED: size matches the panel,
display()is called, color is set. - Memory: buffer fits, strings use
F(). - Library: matches your backpack or module.
Exercise
Your 16x2 LCD behind an I2C backpack lights its backlight but shows no text. The scanner reports a device at 0x3F, and your sketch uses 0x27. What do you change first, and what do you try next if the screen is still blank?
Show answer
Change the address in the LiquidCrystal_I2C constructor to 0x3F, then re-upload. If the screen is still blank, turn the blue contrast trimmer on the backpack, since a wrong trimmer position hides text even when communication works. After that, try a different LiquidCrystal_I2C library fork.
Exercise
A 128x64 SSD1306 sketch freezes after upload and the screen stays dark. Serial prints nothing after "SSD1306 allocation failed or not found". Name two different causes and how you would tell them apart.
Show answer
The display may not answer at the given address, or the library may have failed to allocate the 1024-byte frame buffer. Run the I2C scanner: if no address appears or the address differs from the sketch, it is a wiring or address problem. If the scanner finds the display at the right address, check the compile output for high RAM use and shrink strings and arrays.
Exercise
A counter on an LCD goes from 100 down to 99 but the screen shows 990. Why, and how do you fix it without calling lcd.clear()?
Show answer
print() only writes the characters you send, so the old last digit "0" stays in the third column. Print trailing spaces after the number, for example lcd.print(" ");, or format the value into a fixed-width field so every update overwrites the full area.