Ad Code

Responsive Advertisement

Ticker

6/recent/ticker-posts

Interface Arduino With LCD

Interface Arduino With LCD




In this tutorial i will take you through the process of interfacing Arduino UNO with a Liquid crystal display (LCD). If you haven't gone through my previous post on Reading a Switch with Arduino and you love to do so, click here .


 LCDs are alphanumeric or graphical displays and they are widely used in microcontroller based applications. In resent years, LCDs are replacing LEDs and Seven segment displays due to:
  • Declining price of LCDs
  • Ease to programming for characters and graphics
  • Ability to display numbers, characters and graphics unlike LEDs which can display only numbers and a few characters. 
LCDs comes in different sizes some can display up to forty (40) characters with up to four (4) lines       ( rows and columns) with each character consisting of a 5x8 or 5x11 dot matrix.
In this tutorial we will focus on the 16x2 Hitachi HD44780 LCD (i.e. 16 characters (columns) and two lines(rows) ).

We have :
  1. Serial LCDs
  2. Parallel LCDs
Serial LCDs are connected to the microcontroller using one data line and the data is transferred using the RS232 serial communication protocol. The serial LCDs are easy to use but more expensive than the parallel LCDs. In this article we will concentrate on the parallel LCDs.

LCD Pin Description:

  1. VSS       -----------  Ground pin
  2. VCC      ----------- +5V power supply
  3. VEE      -----------  power supply to control contrast
  4. RS         -----------  RS = 0 to select command register, RS = 1 to select data register.
  5. R/W      -----------  R/W = 0 for write, R/W = 1 to read.
  6. E           -----------  Enable pin
  7. DB0      ----------    8 bit data bus
  8. DB1     ----------    8 bit data bus
  9. DB2      ----------    8 bit data bus
  10. DB3     ----------    8 bit data bus
  11. DB4      ----------    8 bit data bus
  12. DB5      ----------    8 bit data bus
  13. DB6      ----------    8 bit data bus
  14. DB7      ----------    8 bit data bus

If RS = 0, the instruction "command" code register is selected and the user can send a command such as " clear display, cursor at home etc."
If  RS = 1, the "data" register is selected and the user can send a data to be displayed on the LCD screen.

The Arduino Programing language has a list of functions that makes interfacing the Arduino board with an LCD very easy all you need to do is to include the LCD Library to our code as will be seen in the code section. Check out these functions here.

Circuit Diagram




CODE:

/*
    Name     : Interfacing Arduino with LCD
    Author   : Daniel Oluwole
                       (C) 2020 Danitronics
                       danieloluwole51@gmail.com, danieloluwole51@yahoo.com
    Mobile:    +234 8188508765.
   
    Notes    :   Our aim is to display the word "DANITRONICS" on the LCD Screen
*/

// include the library code:
#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);

  
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(3, 0);
  // print the number of seconds since reset:
  lcd.print("DANITRONICS");    // Print a message to the LCD.
}



Next Post:

Post a Comment

0 Comments

Ad Code

Responsive Advertisement