Pages: [1]   Go Down
Author Topic: LCD1602 with AtMega2560  (Read 934 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

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 Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Full Member
***
Karma: 5
Posts: 206
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Worst state in America
Offline Offline
God Member
*****
Karma: 24
Posts: 672
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

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

South Africa
Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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).

http://www.dfrobot.com/wiki/index.php?title=I2C/TWI_LCD1602_Module_%28SKU:_DFR0063%29
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 65
Posts: 6914
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Online
Brattain Member
*****
Karma: 551
Posts: 46213
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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 Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

// 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 Online
Brattain Member
*****
Karma: 551
Posts: 46213
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.

Quote
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

Pages: [1]   Go Up
Jump to: