So im currently doing some practice and im doing hello world at UNO R3 and its working very fine.
but then when i tried in Arduino Mega 2560 it's not working. only White LCDs/Boxes appearing on the LCD even though they have a literally similar code. i change Board set to mega2560, change COM correctly and recheck the wire and for some reason it is still not working.
i wonder what is wrong??
code:
#include "LiquidCrystal.h"
// initialize the library by providing the nuber of pins to it
LiquidCrystal lcd(8,9,4,5,6,7);
void setup() {
lcd.begin(16,2);
// set cursor position to start of first line on the LCD
lcd.setCursor(0,0);
//text to print
lcd.print(" 16x2 LCD");
// set cusor position to start of next line
lcd.setCursor(0,1);
lcd.print(" DISPLAY");
}
void loop()
{}
I wired up a 1602 display to my Mega and tried your code. Works fine. Displays "16x2 LCD" centered on line 0 and "DISPLAY" centered on line 1. Code is OK, suspect the wiring or contrast adjustment. See below for information on wiring the contrast pot. Inspect the wiring and test the integrity of your jumper wires.
Almost all of the LCD tutorials have the wiring of the contrast pot wrong. It is a mistake that has been perpetuated through the years. The right way is to wire the one end of the pot to ground and the wiper to LCD pin 3 (V0). The other end of the pot is left disconnected. So the pot is a variable resistor. Actually I find that a 1K fixed resistor from ground to Vo gives me satisfactory contrast on virtually every LCD that I have tried.
If you need better support, show clear pictures of your controller, the LCD, the pot and each and every wire between them. use meaningfull colors for your wires, and describe what you have connected to what. When you care about good pictures and a good description you might be able to spot the mistake on your own.