Offline
Newbie
Karma: 0
Posts: 6
|
 |
« on: April 28, 2012, 12:06:55 pm » |
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
Faraday Member
Karma: 17
Posts: 3507
|
 |
« Reply #1 on: April 28, 2012, 04:36:14 pm » |
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
Faraday Member
Karma: 38
Posts: 6056
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #2 on: April 28, 2012, 07:19:47 pm » |
lcd1.setCursor(2,2); lcd2.setCursor(5,2); There is no second row. The rows only run between 0 and 1 for your 16X 2 displays.
|
|
|
|
|
Logged
|
|
|
|
|
Western New York, USA
Offline
Faraday Member
Karma: 17
Posts: 3507
|
 |
« Reply #3 on: April 28, 2012, 08:35:34 pm » |
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
Newbie
Karma: 0
Posts: 6
|
 |
« Reply #4 on: April 29, 2012, 08:40:12 am » |
@ 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.  thank you.
|
|
|
|
|
Logged
|
|
|
|
|
Phoenix, Arizona USA
Offline
Faraday Member
Karma: 30
Posts: 5123
Where's the beer?
|
 |
« Reply #5 on: April 29, 2012, 11:06:30 am » |
i din know the row initialization started from 0.  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
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 53
|
 |
« Reply #6 on: November 19, 2012, 10:03:43 am » |
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
Faraday Member
Karma: 38
Posts: 6056
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #7 on: November 19, 2012, 10:47:27 am » |
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
Jr. Member
Karma: 0
Posts: 53
|
 |
« Reply #8 on: November 19, 2012, 10:55:49 am » |
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
Jr. Member
Karma: 0
Posts: 53
|
 |
« Reply #9 on: November 19, 2012, 10:59:47 am » |
As for the code, i used the LCD example in the Arduio IDE, which worked fine with Arduino before.
|
|
|
|
|
Logged
|
|
|
|
|
Central MN, USA
Offline
Faraday Member
Karma: 38
Posts: 6056
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #10 on: November 19, 2012, 11:20:25 am » |
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
Jr. Member
Karma: 0
Posts: 53
|
 |
« Reply #11 on: November 19, 2012, 12:41:14 pm » |
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
Faraday Member
Karma: 38
Posts: 6056
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #12 on: November 19, 2012, 02:04:59 pm » |
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
Faraday Member
Karma: 17
Posts: 3507
|
 |
« Reply #13 on: November 19, 2012, 02:09:27 pm » |
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
Jr. Member
Karma: 0
Posts: 53
|
 |
« Reply #14 on: November 19, 2012, 03:02:47 pm » |
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
|
|
|
|
|
|