I have LCD1602 shield paired with mega2560 (Link to the setup). I am trying to print Hello World on the display. But for some reason it is not working.
My code compiles fine in Atmel studio 6 and uploads on the board, but nothing gets printed. There are just 16 blocks being displayed in the first row. Here is the code.
#define LCD_RS 8
#define LCD_EN 9
#define LCD_D4 4
#define LCD_D5 5
#define LCD_D6 6
#define LCD_D7 7
// initialize LCD object
LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
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);
}
I tried several combinations of pins that I thought were logically correct. But none of them worked.
I just looked at the bottom of the LCD. It seems like "E" is not connected to any pin. So when I mount the shield on the board, pin 9 on the board that goes to the shield does not connect to "E". Am I missing something here? Or is it that my shield has a manufacturing defect?
rbaustin:
I just looked at the bottom of the LCD. Am I missing something here?
Very likely, try the top of the board, and you may find it.
Your code does not include the liquid crystal library, and I imagine that would be essential, no matter what you use to write it. I submit you would be better off using the standard Arduino IDE - if only because I'm pretty sure it would refuse to compile with a missing library.
Further, there are differences in the pin arrangements among various 16x2 shields. While your pin code is the same as mine, I believe it might be unusual. You should check the data sheet, if you have one.
My code includes LiquidCrystal library. As I mentioned in my OP that I am able to successfully compile and link the code. It also uploads to the board.
I also tried using standard Arduino IDE, but it did not work. Ohh may be I did not try with the correct pin numbering when I compiled in Arduino IDE. I will try that and report my findings.
Will also look at the top of the board and see if there is any connection to the "E" pin.
I have LCD1602 shield paired with mega2560 (Link to the setup). I am trying to print Hello World on the display. But for some reason it is not working.
My code compiles fine in Atmel studio 6 and uploads on the board, but nothing gets printed. There are just 16 blocks being displayed in the first row. Here is the code.
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);
}
I tried several combinations of pins that I thought were logically correct. But none of them worked.
Thanks for your help.
At a bare minimum, an HD44780 compatible LCD needs:
RS - register select
RW - tied to ground
EN - enable (also called "E").
D4 thru D7 - highest 4 bits of the data bus
The Arduino LiquidCrystal library will work if you don't connect RW to a pin, but then you have to manually ground the RW pin (to lock the LCD in "write" mode).
I haven't worked with this module, but if I was you I would abandon this LCD module and replace it with the I2C version which only needs two wires connected and doesn't waste I/O's (actually 4 wires including +5v and ground).
rbaustin:
I just looked at the bottom of the LCD. It seems like "E" is not connected to any pin. So when I mount the shield on the board, pin 9 on the board that goes to the shield does not connect to "E". Am I missing something here? Or is it that my shield has a manufacturing defect?
Finally success!! Just came home from work and tried uploading the code through Arduino ide with the following pins ( lcd(8, 9, 4, 5, 6, 7)) and it worked!! These were the same pin numbers that I was using when I tried uploading through Atmel Studio 6. So I am like what?? Why is it working when I upload using Arduino ide and why din't it work last night when I tried the same code through AS6.
Then I said ok, let me try uploading the same code using AS6, and voila! It worked.... So, now I am totally confused as to why it dint work last night and why is it working today....
1 possible explanation (which you guys can correct me if I am wrong) is that there seemed to be a very thin soldering metal on the route that connects the pin from my board to the "E" slot on the top side of the lcd board. I just removed it using my mailbox key. Is it possible that it was shorting something? I should have tried uploading the code before removing that soldering piece and that would have answered my question....But well....
Anyways.. I am happy that its working now, so I can continue with my project.
Thanks for your help!!
// LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// The pins above gave me solid blocks.
// The pins below gave me the correct display
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
// and the reset button starts the count over.
2 and 3 appear to be interrupt 0 and interrupt 1
11 and 12 are MOS1 and MIS0
4, 5, 6, 7, 8, 9 don't have anything but 'digital PWM'
Maybe someone can explain the problem, but thanks for the correct pin out.
Anthony
They are, but, unless you are attaching something to them that can generate an interrupt AND registering a handler, using the pins is no problem.
11 and 12 are MOS1 and MIS0
Correct on a UNO or other 328 based board, but not on a Mega, and only if you use SPI.
The order of the pins that didn't work and the the order of the pins that do work is not the same. I wonder if that has anything to do with the failure to print with the first set of pins.