LCN 2004A1 is a 20x4 LCD (20 columns, 4 rows)! The contrast fix is still the same, but let me give you the correct setup:
Step 1: Fix Contrast (Same as before)
Connect LCD pin 3 (V0) to GND temporarily to test. If squares turn dark, use a 10kΩ potentiometer or 1kΩ-10kΩ resistor to GND.
Step 2: Wiring for 20x4 LCD
Same wiring as before:
LCD Pin → Arduino Uno Pin
VSS (1) → GND
VDD (2) → 5V
V0 (3) → Contrast control (potentiometer or resistor to GND)
RS (4) → Digital Pin 12
EN (5) → Digital Pin 11
D4 (7) → Digital Pin 5
D5 (8) → Digital Pin 4
D6 (9) → Digital Pin 3
D7 (10) → Digital Pin 2
A (15) → 5V (backlight)
K (16) → GND (backlight)
Step 3: Correct Code for 20x4
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.begin(20, 4); // 20 columns, 4 rows
lcd.print("Hello, World!");
lcd.setCursor(0, 1);
lcd.print("Row 2");
lcd.setCursor(0, 2);
lcd.print("Row 3");
lcd.setCursor(0, 3);
lcd.print("Row 4");
}
void loop() {
// Empty
}
Comments1
Test
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4); // Address, columns, rows
void setup() {
lcd.init();
lcd.backlight();
lcd.print("Hello, World!");
}
void loop() {
// Empty
}