Offline
Newbie
Karma: 0
Posts: 8
|
 |
« on: December 27, 2012, 09:49:58 pm » |
Hi, 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. Thanks for your help.
|
|
|
|
« Last Edit: December 27, 2012, 09:51:39 pm by rbaustin »
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 8
|
 |
« Reply #1 on: December 27, 2012, 10:35:38 pm » |
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?
Thanks
|
|
|
|
|
Logged
|
|
|
|
|
Dee Why NSW
Offline
Full Member
Karma: 5
Posts: 206
|
 |
« Reply #2 on: December 27, 2012, 11:57:57 pm » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 8
|
 |
« Reply #3 on: December 28, 2012, 12:35:28 pm » |
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.
Thanks.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 15
Posts: 463
|
 |
« Reply #4 on: December 28, 2012, 02:14:55 pm » |
Hi, 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. 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).
|
|
|
|
|
Logged
|
|
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 38
Posts: 6050
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #6 on: December 28, 2012, 05:56:52 pm » |
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?
Thanks
Can you provide a couple pictures?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 8
|
 |
« Reply #7 on: December 28, 2012, 08:52:31 pm » |
Hello folks,
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!!
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Online
Brattain Member
Karma: 334
Posts: 36443
Seattle, WA USA
|
 |
« Reply #8 on: December 29, 2012, 07:55:15 am » |
Is it possible that it was shorting something? Too bad you didn't take a good picture first. Yes, it could have been shorting something.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 1
|
 |
« Reply #9 on: January 10, 2013, 04:48:36 pm » |
// 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
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Online
Brattain Member
Karma: 334
Posts: 36443
Seattle, WA USA
|
 |
« Reply #10 on: January 10, 2013, 05:58:43 pm » |
2 and 3 appear to be interrupt 0 and interrupt 1 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.
|
|
|
|
|
Logged
|
|
|
|
|
|