Arduino Uno 1602 LCD Display

Embedded
Electronics
Published

October 25, 2019

Modified

October 25, 2019

Breadboard Setup

List of required components:

Pcs. Name Description
1 LCD 1602 LCD Module (with pin header)
1 POT Potentiometer
1 R1 Resistor 220Ω

Circuit Schemstics

Connections on the breadboard and Arduino:

Code

The Arduino development environment provide a LiquidCrystel library to control LCD screens. In the following example a variable lcd is initialized and the LCD screen dimensions configured before printing a text:

#include <LiquidCrystal.h> // library to control LCDs

/* Initialize the library with the pins connected to the LCD
 *
 * - Creates a variable of type LiquidCrystal called `lcd`
 * - Uses the register select pin RS and the enable signal pin E
 * - 4 pins used for data lines D4 up to D7
 */
LiquidCrystal lcd(12, 11, 5,  4,  3,  2 );
//                RS, E,  D4, D5, D6, D7

void setup() {
  // Configure the LCD screens dimensions (width/height)
  lcd.begin(16,2); // 16 characters by two lines
  // Print text to the screen
  lcd.print("...");
}

void loop() {}

The library provide multiple function to display and position content on the screen:

[]

const int sec = 1000;

void loop() {
  delay(sec);
  // Clear the screen
  lcd.clear();
  // Position the LCD cursor at the 10th column, in the second row
  lcd.setCursor(10,1);
  // Set the display to scroll automatically, by pushing previous
  // characters one column to the left
  lcd.autoscroll();
  int i;
  // Display the numbers 0 up to 9
  for(i = 0; i < 10; i++) {
    lcd.print(i);
    delay(sec);
  }
}