Interfacing LCD 16*2 with Arduino
16x2 LCD Display
The LCD (Liquid Crystal Display) a 16x2 means it can display 16 characters per line and there are 2 such lines, in his LCD each character is displayed in a 5x7 pixel matrix.
A Read/Write (R/W) pin that selects reading mode or writing mode
An Enable pin that enables writing to the registers
8 data pins (D0-D7) .
The states of these pins (high or low)are the bits that you're writing to a register when you write or the values you're reading when you read
there is also a display contrast pin (v0), power supply pins (+5v and Gnd ), and LED backlight (+a,-k) pins that you can use to power the LCD, control the display contrast and turn on and off the LED backlight, respectively
the Liquid Crystal Library <LiquidCrystal.h>
Interfacing 16x2 LCD with Arduino
code
#include <LiquidCrystal.h> // includes the LiquidCrystal Library LiquidCrystal lcd(12, 11, 5, 4, 3, 2);// Creates an LC object. Parameters: (rs, enable, d4, d5, d6, d7)
void setup() { lcd.begin(16,2); // Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of the display } }
void loop() { lcd.print("REDDIX"); // Prints "REDDIX" on the LCD delay(1000); // 3 seconds delay lcd.setCursor(2,1); // Sets the location at which subsequent text written to the LCD will be displayed lcd.print("LCD Tutorial"); delay(2000); lcd.clear(); // Clears the display lcd.blink(); //Displays the blinking LCD cursor delay(500); lcd.setCursor(7,1); delay(500); lcd.noBlink(); // Turns off the blinking LCD cursor lcd.cursor(); // Displays an underscore (line) at the position to which the next character will be written delay(500); lcd.noCursor(); // Hides the LCD cursor lcd.clear(); // Clears the LCD screen }
#include // includes the LiquidCrystal Library
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);// Creates an LC object. Parameters: (rs, enable, d4, d5, d6, d7)
void setup() {
lcd.begin(16,2); // Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of the display }
}
void loop() {
lcd.print("REDDIX"); // Prints "REDDIX" on the LCD
delay(1000); // 3 seconds delay
lcd.setCursor(2,1); // Sets the location at which subsequent text written to the LCD will be displayed
lcd.print("LCD Tutorial");
delay(2000);
lcd.clear(); // Clears the display
lcd.blink(); //Displays the blinking LCD cursor
delay(500);
lcd.setCursor(7,1);
delay(500);
lcd.noBlink(); // Turns off the blinking LCD cursor
lcd.cursor(); // Displays an underscore (line) at the position to which the next character will be written
delay(500);
lcd.noCursor(); // Hides the LCD cursor
lcd.clear(); // Clears the LCD screen
}
Comments
Post a Comment