How to use 16×2 lcd display with arduino

In this tutorial, we will explore advanced functionalities of a standard 16×2 character LCD with an Arduino Uno, including custom characters, contrast control, and backlight management. 

 📝 Required components

  • Arduino Uno
  • 16×2 Character LCD (HD44780-based)
  • Potentiometer (10kΩ) for contrast
  • 220Ω resistor (for backlight)
  • Breadboard
  • Jumper wires

Step 1: Wiring the Electronics 

1 Connect VSS to GND and VDD to 5V on Arduino. 

2 Wire VO to middle pin of 10kΩ potentiometer; ends to 5V and GND for contrast adjustment. 

3 Connect RS to pin 12, E to pin 11, D4–D7 to pins 5, 4, 3, 2 respectively. 

4 Backlight anode (A) through 220Ω resistor to 5V; cathode (K) to GND. 

🖥️Step 2: Writing the Code

This is the complete code to use the button with Arduino:

				
					#include <LiquidCrystal.h>

// Connections: RS=12, E=11, D4=5, D5=4, D6=3, D7=2
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  lcd.begin(16, 2);            // Initialize a 16×2 LCD
  lcd.print("Welcome to");      // Print a welcome message
  lcd.setCursor(0, 1);          // Move cursor to column 0, line 1
  lcd.print("Arduino LCD!");
}

void loop() {
  // Nothing to do here for this basic example
}

				
			

🔎 Breaking down the Code

Let’s review the code section by section:

				
					LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
				
			

Declares which Arduino pins are connected to RS, E, D4, D5, D6, and D7.

				
					lcd.begin(16, 2);
				
			

Tells the library the display size (16 columns by 2 rows).

				
					lcd.print("…");
				
			

Prints text starting at the current cursor position.

				
					lcd.setCursor(column, row);
				
			

Moves the cursor to the specified column (0–15) and row (0 or 1).

🛠️Troubleshooting

 

Relay does not change state:

  • If display is blank, adjust contrast potentiometer. 

    Ensure correct wiring of RS, E, and Data pins. 

en_US