Connecting LCD to Arduino to display various things is fun if you know how to. It is very simple just follow the simple steps.
- Gather the things necessary to do so like Arduino (mega 2560 for example), LCD display(16x2), Jumper Wires, Potentiometers (1k/10k).
- Make the connections as shown in the circuit diagram. I this example we are using Arduino mega 2560. You can use any of the Arduino just the connections and the coding will change.LCD 1(VSS) to Arduino GNDLCD 2(VCC) to 5VLCD 3(VEE) to Arduino GND via a potentiometer (10K)LCD 4(RS) to Arduino pin 12LCD 5(R/W) to Arduino GNDLCD 6(E) to Arduino pin 11LCD 11(DB4) to Arduino pin 5LCD 12(DB5) to Arduino pin 4LCD 13(DB6) to Arduino pin 3LCD 14(DB7) to Arduino pin 2LCD 15(LED+) to 5V via potentiometer (10K)The pin 3 potentiometer will control the contrast of the display. The pin 15 and 16 are for the backlight and the potentiometer to control the brightness. Remember that the display works only on 5V so applying more voltage will burn your display
- Next is the coding which is the easiest part:
#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);
}
void loop()
{
//clear the screen before writing anything
lcd.clear();
/*anything to be written in double inverted commas in void loop will be updated every cycle*/
lcd.print("HELLO WORLD");
//delay so that our screen will not be just seen flashing
delay(1000);
}
The Arduino has the liquid crystal library so the program is made much easier. To add your own text just replace the text in the double inverted commas. If you want to display some permanent text put it in the void setup(). If you want to update the text every cycle put it in the void loop(). Don’t forget to add lcd.clear() to clear the screen before printing or else it will print upon it again and again. Also, put a delay after the print line so that your screen does not seem to flash.
Have fun with the display putting your own code. If you want I can post how to connect multiple displays too.