Pages: [1]   Go Down
Author Topic: how to interface 2 [16x2 jhd 162a] lcd screens with one atmega 8 board  (Read 3580 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 35
Posts: 4299
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: April 28, 2012, 04:44:36 pm by floresta » Logged

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

Quote
Code:
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.
Logged


Western New York, USA
Offline Offline
Faraday Member
**
Karma: 35
Posts: 4299
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
« Last Edit: April 28, 2012, 08:40:35 pm by floresta » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@ 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.  smiley-razz
thank you.
Logged

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 40
Posts: 5570
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

i din know the row initialization started from 0.  smiley-razz

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

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

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

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


Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

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


Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

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

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


Western New York, USA
Offline Offline
Faraday Member
**
Karma: 35
Posts: 4299
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: