Thursday, 14 May 2015

Arduino lesson 10 : Interfacing 16*2 LCD with Arduino UNO

Intro to topic :

Now once you have got some confidence of using some very basic operation from your arduino board in last tutorials. Now its time to take our efforts to next level of interfacing external hardware i.e LCD display (16*2) 

Hardware required :

  1. Arduino UNO board.
  2. LCD (of any color)
  3. POT 500ohm - 1Kohm (for controlling LCD brightness)
  4. Resister 560ohm (not mandatory)
  5. Connecting wires/Jumper wires.
  6. PC to configure arduino board (with arduino software installed).
  7. Bread board.


Steps to follow :


  1. Connect the Lcd according to Fritzing image
  2. The resister if added good otherwise it is not necessary to put on resister because the current is limited to each pin of arduino boards.
  3. After this connect the board to PC by USB cable and then open up the IDE in PC.
  4. Goto File>Examples>LiquidCrystal>HelloWorld
  5. The following Code will open.



Code to be uploaded :

/*
  LiquidCrystal Library - Hello World

 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 "Hello World!" 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
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 1K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)


 */

// 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("hello, world!");
}

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);
}




Once you have uploaded the code correctly just see that Lcd will turn on and the word "hello world" will be shown on screen if not then change the value of POT resistor to change lcd contrast and brightness.

No comments:

Post a Comment