how to interface 2 [16x2 jhd 162a] lcd screens with one atmega 8 board

my project requires me to interface 2 16x2 lcd's on one Arduino atmega 8 board. individually they work but wen i connect both of them simultaneously only the first lcd works. how to resolve this problem?
this the sample test program is:
#include <LiquidCrystal.h>
LiquidCrystal lcd1(2,3,4,5,6,7);
LiquidCrystal lcd2(8,9,10,11,12,13);
void setup()
{
Serial.begin(9600);
lcd1.begin(16,2);
lcd1.print("Speed in RPM:");
lcd2.begin(16,2);
lcd2.print("Temp in 'C:");
}
void loop()
{

lcd1.setCursor(2,2);
lcd2.setCursor(5,2);
lcd1.print("I/P Req");
lcd2.print("I/P Req");
delay(1000);
}
plz give inputs on how to resolve this.

It's easier than that, you only need seven I/O pins for the two LCDs.
Look here for all the details: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1265969050

Also:
Why are you using serial.begin() ?
What is the purpose of your loop() ?
What do you expect to see on a two line display when you set the cursor to the third line with a statement like

lcd1.setCursor(2,2);

?

Don

lcd1.setCursor(2,2);

lcd2.setCursor(5,2);

There is no second row. The rows only run between 0 and 1 for your 16X2 displays.

There is no second row. The rows only run between 0 and 1 for your 16X2 displays.

But there is a second row. It's below the first row. There is no row numbered 2.
I thought it would be good for him to figure this part out, hence my third question.

Don

@ floresta: thank you. the display is working fine now. 1&2. serial begin is there because the program is still being written and is the reason for void loop is also the same. interfacing the lcd(s) was my first concern. now that it is taken care of i can finish the program. 3. i din know the row initialization started from 0. :stuck_out_tongue:
thank you.

overlord46:
i din know the row initialization started from 0. :stuck_out_tongue:

Get this through your head early:

There is little in computing or software development in which numbering (aka, indexing) -doesn't- start at zero (0); in fact, you should make it a habit to assume it starts at zero, and only adjust your expectations when/if you learn otherwise.

How did you interface a 16x2 LCD with an ATMEGA8? I mean connections. I tried considering the Arduino tutorial and din't succeed. I succesfully did it using the Arduino, but when I tried with a barebone Atmega - nothing happened. Could you please post the connections between the Atmega 8 and the LCD?

I am using the Arduino IDE and an Atmega8 for the moment.

Thank you!

Can you confirm the ATMEGA8 is working with, say flashing an LED? What kind of testing code are you using for LCD? I assume you know how to connect the LCD since you did it with an arduino.

The Atmega8 works ok, both digitally and analog (the ADCs I mean). I will retry the connections, maybe I missed something. What (Arduino) pins configurations do you recommend, 7...12 or others? Does it matter?

As for the code, i used the LCD example in the Arduio IDE, which worked fine with Arduino before.

claudiu_mirescu:
As for the code, i used the LCD example in the Arduio IDE, which worked fine with Arduino before.

What about combining and LED flashing or serial print and LCD sample code? This way you know where the program gets stuck.

Succeeded! Just followed the Arduino tutorial. It looks like a cat was on my desk and played with the wires (on the breadboard, I mean), but it works.

I made a terrible beginner (which I am) mistake the first time I tried: I relied on the power supply from the avrisp programmer and it simply was not enough power for both the backlight and the logic of the LCD. Now I used external power after upload (and after disconnecting the programmer) and it works just fine.

Just one thing: millis() for Atmega8 and Attiny13 is, in fact, ten times more, hundredths of second.

Thank you!

Good to know it works now. Try adding some resistor in series with the back light, like 220 ohm.

Just one thing: millis() for Atmega8 and Attiny13 is, in fact, ten times more, hundredths of second.

Are the fuses set properly and have you selected the correct 'board'?

Don

I have selected Arduino NG/Atmega8, because the barebone Atmega8 does not work. But I do not know anything about fuses, and I always avoided to play with them, afraid I could harm the uC. I will read about them, because I think it is more to uCs than what I use them for.