Wednesday, 6 April 2016

Interfacing lcd with arduino

How to interaface lcd (4-bit interface) with arduino?

In this tutorial, we are going to discuss , how to interface lcd with arduino.

We are using 16*2 lcd, means it have two rows and 16 columns. Overall, we can display 32 characters.
16*2 alphanumeric lcd
16*2 LCD

Lcd have 16 pins, out of which six are connected to arduino. D4-D7 are data pins. RS, RW and EN pins are also there. RW pin is permanently grounded since we are writing to lcd.
Pin no 3 is connected to pot (10k) in order to change the contrast. Pin no 15 and 16 are for backlight.
Since lcd don't have any backlight.

Code:

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

Proteus simulation of arduino uno
Simulation in proteus
Hope, you had enjoyed the tutorial.

Stay tuned for more updates !!

No comments:

Post a Comment