Friday, June 12, 2015

LCD interfacing with arduino

In this tutorial we’ll be looking at how to connect interface parallel LCD to an Arduino. We are using 16 char x 2 Line LCD known as 16x2 LCD, you can usually identify this display by the 16-pin interface. You only need to solder 10 of the 16 wires to use the LCD, but this will only enable you to use the 4-bit interface. 4-Bit interface helps us to reduce required IO lines, there are various displays available such as 16x2, 16x4, 20x2, 20x4 LCD Display.
16x2 LCD Display


Step 1: Components Required
1.   16x2 LCD
2.   Arduino Board
3.   Connecting wires
4.   1K Ohm Resistor

Step 2: Circuit diagram/connections
1. Most of the time we don’t need to read the display so we always write on the display. Pin 5 RD/WR  when it is connected to logic 0, It is write operation, to reduce IO requirement we connect it to GND (Logic 0 Always Write)

2. Contrast setting, LCD contrast can be adjusted by setting proper voltage at Pin 3. Connecting variable resistor takes lot of space and possibility of setting wrong contrast value due to change in resistance with change in atmospheric condition. I use 1KOhm resistor between GND and Pin 3. It gives perfect contrast setting.


As I mentioned before, you only need to connect 10 pins.  Solder jumpers to these wires:


Pin 1 - Ground
Pin 2 - +5V
Pin 3 - Contrast Adjustment (1K Ohm resistor to GND)
Pin 4 - Register Select
Pin 5 - Read/Write (Connect to GND)
Pin 6 - H/L Enable
Pin 11 - DB4
Pin 12 - DB5
Pin 13 - DB6
Pin 14 - DB7

As shown in the picture below:

Pin 1 to GND
Pin 2 to 5V
Pin 3 to (1K Ohm resistor to GND)
Pin 4 to Arduino pin 12
Pin 5 to GND
Pin 6 to Arduino pin 11
Pin 11 to Arduino pin 5 
Pin 12 to pin 4
Pin 13 to pin 3
Pin 14 to pin 2

LCD Interfacing with Arduino
Step 3: Programming of Arduino
Code

/*
This tutorial Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the 
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.
 
 This sketch prints "circuits4you.com" to the LCD
 and shows the time.
 
  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 1K resistor:
 * One end to ground
 * Another end to LCD VO pin (pin 3)
 
 This example code is in the public domain.
 */

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

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("circuits4you.com");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}

Step 4: You will see circuits4you.com on display
1. Share
2. Like
3. Follow us on Google+



No comments:

Post a Comment