16x2 LCD Interfacing With Arduino

ARDUINO Tutorial Series

Interfacing of 16x2 LCD with Arduino

LCD Can Display Your Name..!!

Conributed By :- Vedant Patil

-----------------------------------------------------------

LCD Basics

LCD (Liquid Crystal Display) screen is such a display module that are replacing seven

segments and other multi segment LEDs for these purposes.

The reasons being: LCDs are economical, easily programmable, have no limitation of displaying special & even custom characters (unlike in seven segments), animations and so on. LCD can be easily interfaced with a microcontroller to display a message or status of a device.

 

A 16x2 LCD means it can display 16 characters per line and there are 2 such lines.

LCD needs 5v for its operation along with 200mA of current.

LCD is used to display the numbers/symbols , special characters.

 

 An practical LCD looks like this:-

     

Now, Programming LCD using an ARDUINO UNO

 

Basic syntax for LCD in ARDUINO IDE

 

  • Header file for LCD  // #include

 

  • Pin configuration

1. When connected in 8bit- mode

LiquidCrystal lcd(rs,rw,en,d0,d1,d2,d3,d4,d5,d6,d7);

2. When connected in 4-bit mode

LiquidCrystal lcd(rs,rw,en,d4,d5,d6,d7);

Note-we can provide ground to “rw” pin so that we can reduce the total number of pins required.

 

1. when connected in 8bit- mode

LiquidCrystal lcd(rs,en,d0,d1,d2,d3,d4,d5,d6,d7);

2. when connected in 4-bit mode

LiquidCrystal lcd(rs,en,d4,d5,d6,d7);

 

Here c stands for ‘column’ and r for ‘row’

  • lcd.begin(16,2);                      //To begin Lcd  // As we use a 16*2 LCD here
  • lcd.clear();                              // To clear lcd screen
  • lcd.home();                            // Cursor will appear on c=0&r=0
  • lcd.setCursor(c,r);                  //To set position of cursor
  • lcd.scrollDisplayRight();        // shift text right  //In proteus it will shift text left
  • lcd.scrollDisplayLeft();           // shift text left    // Not work in proteus
  • lcd.print();                             // To print text

 

Task 1:- To print “embedded informatics” on a 16*2 LCD using an ARDUINO uno.

 

There are two ways to perform above task

In 8bit-mode

Source code:-

#include

LiquidCrystal lcd(0,1,2,3,4,5,6,7,8);

void setup()

{

for(int i=0;i<6;i++)

{

pinMode(i,1);

}

lcd.begin(16,2);

lcd.clear();

lcd.print("embedded");

lcd.setCursor(0,1);

lcd.print("informatics");

}

 

void loop()

{

}

 

In 4-bit mode

Source code:-

#include

LiquidCrystal lcd(0,1,2,3,4,5,6,7,8);

void setup()

{

for(int i=0;i<6;i++)

{

pinMode(i,1);

}

lcd.begin(16,2);

lcd.clear();

}

 

void loop()

{

lcd.clear();

lcd.print("embedded");

delay(500);

lcd.setCursor(0,1);

lcd.print("informatics");

delay(500);

}

 

Simulation Image:-

 

 

CLICK HERE TO VIEW / DOWNLOAD ARDUINO TRAINING SYLLABUS

 

CLICK HERE TO REGISTER NOW FOR ARDUINO TRAINING

 

Top