Go Down

Topic: LCD1602 with AtMega2560 (Read 1 time) previous topic - next topic

rbaustin

Dec 28, 2012, 03:49 am Last Edit: Dec 28, 2012, 03:51 am by rbaustin Reason: 1
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: [Select]
#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.

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?

Thanks

NickPyner


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.


rbaustin

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.

Krupski


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: [Select]
#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).

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

Go Up