Grove LCD RGB Backlight: how it works and fixes
A 16 x 2 character display (16 characters, 2 rows) with a colour backlight. Lab 2b uses it with scrolling text; Labs 3a/3b show sensor values on it. This page covers what the lab sheets do not: how it talks to the Uno, how scrolling really works, and why old characters stay behind.
I2C: two wires, many devices
The LCD uses I2C: one clock wire (SCL) and one data wire (SDA), shared by every I2C device. Each device has an address; the Grove LCD has two inside it: the text controller (0x3E) and the backlight controller (0x62, or 0x30 on newer versions).
| Arduino Uno | Grove cable | LCD |
|---|---|---|
| 5V | Red | VCC |
| GND | Black | GND |
| A4 (SDA) | White | SDA |
| A5 (SCL) | Yellow | SCL |
A4/A5 are the Uno's I2C pins (also labelled SDA/SCL near the USB socket; they are the same pins). You cannot choose other pins for I2C on the Uno.
The functions you will use
| Function | Effect |
|---|---|
lcd.begin(16, 2) | Start the display (in setup()) |
lcd.setRGB(r, g, b) | Backlight colour, 0–255 each: (255,0,0) red |
lcd.setCursor(col, row) | Move the cursor. Column first, both start at 0: (0,1) is the start of the 2nd row |
lcd.print(x) | Write text or a number at the cursor |
lcd.clear() | Blank the screen, cursor to (0,0) |
lcd.scrollDisplayLeft() / Right() | Shift the whole display one place |
lcd.autoscroll() / noAutoscroll() | Text pushes left as you print |
lcd.blink() / cursor() | Show a blinking block / underline cursor |
Why old characters stay behind
lcd.print only writes the characters you give it; it does not erase the rest of the line. Printing 100 and then 99 at the same place shows 990.
Fixes:
- Print spaces after the value to cover leftovers:
lcd.print(distance); lcd.print(" "); - Or clear before redrawing.
lcd.clear()is slow and makes the display flicker if called every loop with no delay; clearing once and rewriting only the changing part looks much better.
How scrolling really works
The display has memory for 40 characters per row, but only shows 16 at a time. scrollDisplayLeft() slides the visible window along that memory by one character. Things to know:
- Both rows scroll together. You cannot scroll one row on its own with these functions. To scroll only one row, print a different slice of your text on that row each time (e.g. with
substring). - Text longer than 40 characters per row wraps oddly. Keep each row under 40.
- Scroll speed is just your
delay()between steps. - After scrolling,
setCursor(0, 0)is still the start of memory, which may now be off screen. Calllcd.home()orlcd.clear()to reset the view.
Numbers on the LCD
lcd.print(25.3456)shows25.35(2 decimals).lcd.print(25.3456, 1)shows25.3.- To show a degree sign:
lcd.print((char)223);(the LCD's own character for °). - Long numbers push text off the edge of the 16 visible characters.
Problems
| Problem | Fix |
|---|---|
| Backlight on, but no text | SDA/SCL swapped (white = A4, yellow = A5), lcd.begin missing, or a 3.3V supply: use 5V. |
| Nothing at all, not even the backlight | No power: check red and black; re-seat the Grove cable. |
| Text correct but backlight off or wrong colour | Backlight is a separate chip: newer LCD versions need an updated library (update it in Library Manager). |
| Old characters left behind | Print spaces over them, or clear (see above). |
| Display flickers | lcd.clear() every loop. Clear once, then overwrite. |
| Random symbols | Loose wire or interference; shorten/replace the Grove cable. |
rgb_lcd.h: No such file or directory | Install Grove - LCD RGB Backlight in the Library Manager. |
Sketch freezes at lcd.begin | The I2C bus is stuck (wrong wiring). Fix wiring, then press RESET. |
Is the LCD there at all?
Upload an I2C scanner sketch (the standard one is on the Arduino website: search "Arduino I2C scanner"). It prints the address of every I2C device it finds in the Serial Monitor. Seeing 0x3E means the LCD is wired correctly and the problem is in your code.