LCD INTERFACING WITH ARDUINO FOR MESSAGE DISPLAY
Introduction:- Liquid crystal display is used with microcontroller to display any message or digital output value. general purpose lcd has 2 row of 16 charactor to display. It is used as output display device. It has 16 pins for connection. pin 1 is connected to ground, pin 2 is connected to + 5 v, pin 3 is connected to potentiometer midile point for lcd contrast control, pin 4 is Registor select pin for selecting data resistor or command Registor. pin 5 is read/write enable. pin 6 is enable pin. pin 7 to pin 14 are for data db0 to db7 respectively. Pin 15 is back light led plus and pin 16 is back light led minus.Circcuit:- Arduino board and lcd display is to be connect as per circuit diagram given below. connect the board with usb cable to pc. copy and paste program given below in Arduino ide. compile and upload the program.liquid crystal libbrary is included in program. functions used are lcd.begin() to initialise lcd disply. lcd.print() to write message in display memory. lcd.disply() to display message and lcd.noDisplay() to turn off message.
All comment are written in blue color and code is in white color.
/* code start (multiline comment)LiquidCrystal Library - display() and noDisplay()
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 uses the
display() and noDisplay() functions to turn on and off
the display.
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
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)*/
// 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);
// In setup() we are using first function lcd.begin(16,2) to initilise lcd with 16 number of //columns and 2 rows.
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// In lcd.print("hello, world") we give command to write hello world in display memory
lcd.print("hello, world!");
}
//The code written in void loop() will repeat continouly
void loop() {
// the function noDisplay() is used to blank (turn off) the display message
lcd.noDisplay();
delay(500); // this provide delay of 500 mili second
lcd.display(); // this function turn on display message
delay(500); // this provide delay of 500 mili second
}
//code ends
// is used to write comment in side the code. The above code to be write on arduino ide compile and load on Arduino board. It will start displaying blinking "hello world" message on lcd display. You can change the message displyed by changing the parameter of lcd.print(" message to display") function. This post will be help full . please comment for any quary and suggestions for improvement.
http://electronicsandmicrocontroller.blogspot.com/2018/07/a-simple-arduino-program-blinking-led.html
No comments:
Post a Comment