How to interface a LCD with Arduino

Post Reply
User avatar
Shehani
Lieutenant
Lieutenant
Posts: 61
Joined: Mon Aug 19, 2013 2:11 pm

How to interface a LCD with Arduino

Post by Shehani » Thu Sep 26, 2013 11:26 am

This demo program helps you to interface a 16×2 LCD display with ARDUINO board. This tutorial is provided assuming that you have basic knowledge in ARDUINO programming. If you didn’t have basic idea about ARDUINO programming.

This programmer 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 :
1.jpg
1.jpg (158.6 KiB) Viewed 4780 times
Code with comment is given below :

Code: Select all

#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.



Article courtesy of electrosome.com
Post Reply

Return to “Arduino”