LCD Interfacing Code with ARDUINO Board

LCD Interfacing Code with ARDUINO Board - This demo program helps you to interface a 16×2 LCD display with ARDUINO board. This tutorial is provided assuming that you have basic knowlede in ARDUINO programming. If you didn’t have basic idea about ARDUINO programming, please refer this tutorial.

This programme displays “Hello World!” on the LCD screen and also shows the time.
The circuit connection should be done as mentioned below:
LCD RS pin to digital pin 9
LCD Enable pin to digital pin 8
LCD D4 pin to digital pin 7
LCD D5 pin to digital pin 6
LCD D6 pin to digital pin 5
LCD D7 pin to digital pin 4
LCD R/W pin to ground
10K potentiometer ends to +5V and ground and wiper to LCD VE pin (pin 3)


Diagram :


Code with comment is given below :
#include<LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(9, 8, 7, 6, 5, 4);
void setup() {
  // set up the LCD's number of columns and rows: let it be 16x2 LCD display.
  lcd.begin(16, 2);
  // Print a given text on the LCD screen.
  lcd.print("hello, world!");
}
void loop() {
  // set the cursor point to 0th column, 1st line
   lcd.setCursor(0, 1);
  // print the number of seconds since last reset:
  lcd.print(millis()/1000);
}
The LiquidCrystal library also provides these functions:
clear() – clear all text on both lines of the LCD
home() – move the cursor to the to left of the display
setCursor(col, row) – place the cursor at col, row (0,0 is col 1, row 1 and 0,1 is col 1, row 2)
write(x) – write a single character
print(string) – print a string, long, int, etc.

Back To Top