Offline
Newbie
Karma: 0
Posts: 2
|
 |
« on: January 04, 2013, 05:53:02 pm » |
Hi!
I have a problem connecting my LCD and Ethernet shield to my arduino UNO. Everything works fine until i connect my LCD to different pins then (12,11,5,4,3,2). Im trying to use (9,8,7,6,5,4) and (9,8,7,6,5,3). The reason i want to use those pins is because the ethernet shield is using 10-13 and maybe 4. Thats why i tried (9,8,7,6,5,3).
I searched for solutions but all i can find is unsolved threads, people who are suspecting wrong constrast level etc.
Can u help? Thanks!
|
|
|
|
|
Logged
|
|
|
|
|
The Netherlands
Offline
Sr. Member
Karma: 10
Posts: 379
|
 |
« Reply #1 on: January 04, 2013, 07:00:29 pm » |
What problems do you have ? Are the display and the Ethernet Shield the only other hardware you plan to use ?
There's always the possibility to use an adapter to your display so you can use I2C, and free up some ports, if your problems can not be overcome in another way.
|
|
|
|
|
Logged
|
|
|
|
|
Dee Why NSW
Offline
Full Member
Karma: 5
Posts: 206
|
 |
« Reply #2 on: January 04, 2013, 07:11:29 pm » |
The chances of your ethernet using pin 4 are more very good than maybe. It is the typical select pin. You say ethernet and LCD shield. If you have both on one, there would surely be a jumper block so that you can properly set it up. I have never seen ethernet and LCD on the same shield and therefore assume you have exactly the the same problem as I had. My LCD shield uses 8,9,4,5,6,7.
The only solution I could come up with for certain was in fact the obvious one. Use the pototyping shield between the Ethernet and the LCD shields to re-route pin 4 elswhere. In my case:
1. clip off male pin 4 on a proto shield
2. run a jumper thereon from 4 to 16
3. change the sketch to read LCD 8,9,16,5,6,7
You might find that you can run the jumper on the LCD shield, and clip its pin4 instead. My shield looks like it is made to do that, but I wasn't game, and didn't need to.
|
|
|
|
« Last Edit: January 04, 2013, 07:18:46 pm by NickPyner »
|
Logged
|
|
|
|
|
Anaheim CA.
Offline
Edison Member
Karma: 34
Posts: 2404
Experienced old Whitebeard with a Full head of Hair...
|
 |
« Reply #3 on: January 04, 2013, 07:11:56 pm » |
There is also the secret device you are building... without firm data (pictures, sketch and schematic) anything returned would be of the same caliber as what was supplied...
Bob
|
|
|
|
|
Logged
|
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
|
|
|
|
Offline
Newbie
Karma: 1
Posts: 36
...noob...
|
 |
« Reply #4 on: January 04, 2013, 07:53:13 pm » |
that's what I did when i was testing my Ethernet shield wit my Mega 2560 /*LCD CONNECTION LCD 1- ARDU GND + POTENTIOMETER LCD 2- ARDU 5V + POTENTIOMETER LCD 3- POTENTIOMETER MIDDLE LCD 4- ARDU PIN 7 LCD 5- ARDU GND + POTENTIOMETER LCD 6- ARDU PIN 6 LCD 7/8/9/10 - NOT USED LCD 11- ARDU PIN 5 LCD 12- ARDU PIN 4 LCD 13- ARDU PIN 3 LCD 14- ARDU PIN 2 LCD 15- ARDU 5V LCD 16- ARDU GND */
#include <SPI.h> #include <Ethernet.h> #include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
long secs = 50; long minutes = 0; long hours = 0; long days = 0;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; IPAddress ip(192,168,0, 12);
int led1 = 31; //blue int led2 = 32; int led3 = 33;
EthernetServer server(99);
void setup() { lcd.clear(); lcd.begin(20, 4); lcd.setCursor(0,0); lcd.print("LED is OFF"); lcd.setCursor(0,1); lcd.print("LED is OFF"); lcd.setCursor(0,2); lcd.print("LED is OFF"); Serial.begin(9600); pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); digitalWrite(led1,LOW); digitalWrite(led2,LOW); digitalWrite(led3,LOW); Ethernet.begin(mac, ip); server.begin(); }
void loop() { lcd.setCursor(0,3); minutes = ((millis()/1000)/60)%60; hours = (((millis()/1000)/60)/60)%60; days = hours/24;
// 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: secs = (millis()/1000)%60; lcd.print("Timer: "); if (hours>0){ lcd.print(hours); lcd.setCursor(9, 3); lcd.print(":"); } else { lcd.setCursor(9, 3); lcd.print(" "); } if (minutes>0){ lcd.print(minutes); lcd.setCursor(12, 3); lcd.print(":"); } else { lcd.setCursor(12, 3); lcd.print(" "); } if (secs<10){ lcd.print(" "); lcd.print(secs); lcd.print(" "); } else { lcd.print(secs); lcd.print(" "); } EthernetClient client = server.available(); if (client) { boolean currentLineIsBlank = true; String buffer = ""; while (client.connected()) { if (client.available()) { char c = client.read(); Serial.print(c); buffer+=c; if (c == '\n' && currentLineIsBlank) { client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println(); //*********************************************** client.println("<center>"); client.println("<table border=1>"); client.println("<tr>"); client.println("<td>");client.println("<center>"); client.print("BLUE"); client.println("</td>"); client.println("<td>");client.println("<center>"); client.print("GREEN"); client.println("</td>"); client.println("<td>");client.println("<center>"); client.print("RED"); client.println("</td>"); client.println("<td rowspan=4>");client.println("<center>"); client.print("puste"); client.print("<br>"); client.print("puste"); client.println("</td>"); client.println("</tr>"); client.println("<tr>"); client.println("<td>");client.println("<center>"); if (digitalRead(led1)){ lcd.setCursor(0,0); client.print("<font color=red>ON</font>"); lcd.print("LED is ON "); }else{ lcd.setCursor(0,0); client.print("<font color=green>OFF</font>"); lcd.print("LED is OFF"); } client.println("</td>"); client.println("<td>");client.println("<center>"); if (digitalRead(led2)){ lcd.setCursor(0,1); client.print("<font color=red>ON</font>"); lcd.print("LED is ON "); }else{ lcd.setCursor(0,1); client.print("<font color=green>OFF</font>"); lcd.print("LED is OFF"); } client.println("</td>"); client.println("<td>");client.println("<center>"); if (digitalRead(led3)){ lcd.setCursor(0,2); client.print("<font color=red>ON</font>"); lcd.print("LED is ON "); }else{ lcd.setCursor(0,2); client.print("<font color=green>OFF</font>"); lcd.print("LED is OFF"); } client.println("</td>"); client.println("</tr>"); client.println("<tr>");
//kolumna 1 client.println("<td>"); //client.print("<FORM action=\"http://"); client.print(ip); client.print(":99/\" >"); client.print("<form method=get>"); client.print("<P> <INPUT type=\"radio\" name=\"statusb\" value=\"1\">ON"); client.print("<P> <INPUT type=\"radio\" name=\"statusb\" value=\"0\">OFF"); // client.print("<P> <INPUT type=\"submit\" value=\"Submit\"> </FORM>"); client.println("</td>"); //kolumna 2 client.println("<td>"); //client.print("<FORM action=\"http://"); client.print(ip); client.print(":99/\" >"); client.print("<form method=get>"); client.print("<P> <INPUT type=\"radio\" name=\"statusg\" value=\"1\">ON"); client.print("<P> <INPUT type=\"radio\" name=\"statusg\" value=\"0\">OFF"); // client.print("<P> <INPUT type=\"submit\" value=\"Submit\"> </FORM>"); client.println("</td>"); //kolumna 3 client.println("<td>"); //client.print("<FORM action=\"http://"); client.print(ip); client.print(":99/\" >"); client.print("<form method=get>"); client.print("<P> <INPUT type=\"radio\" name=\"statusr\" value=\"1\">ON"); client.print("<P> <INPUT type=\"radio\" name=\"statusr\" value=\"0\">OFF"); // client.print("<P> <INPUT type=\"submit\" value=\"Submit\"> </FORM>"); client.println("</td>"); //koniec tabeki client.println("</tr>"); client.println("<tr>"); client.println("<td colspan='3'>");
client.println("<center>"); client.print("<P> <INPUT type=\"submit\" value=\"Submit\"> </FORM>"); client.println("</center>");
client.println("</td>"); client.println("</tr>"); client.println("</table>"); client.println("</center>"); break; } //************************************************** if (c == '\n') { currentLineIsBlank = true; buffer=""; } else if (c == '\r') { if(buffer.indexOf("GET /?statusb=1")>=0) digitalWrite(led1,HIGH); if(buffer.indexOf("GET /?statusb=0")>=0) digitalWrite(led1,LOW); if(buffer.indexOf("GET /?statusg=1")>=0) digitalWrite(led2,HIGH); if(buffer.indexOf("GET /?statusg=0")>=0) digitalWrite(led2,LOW); if(buffer.indexOf("GET /?statusr=1")>=0) digitalWrite(led3,HIGH); if(buffer.indexOf("GET /?statusr=0")>=0) digitalWrite(led3,LOW); } else { currentLineIsBlank = false; } } } delay(1); client.stop(); } } Lcd wired to ethernet shield this way  Hope that helps,
|
|
|
|
|
Logged
|
-- HE3r0 d(R)ive safe
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 2
|
 |
« Reply #5 on: January 05, 2013, 05:53:24 am » |
What problems do you have ? Are the display and the Ethernet Shield the only other hardware you plan to use ?
There's always the possibility to use an adapter to your display so you can use I2C, and free up some ports, if your problems can not be overcome in another way.
Hi! My problem is that my example text doesn't show up in the LCD, just some random signs, the wiring works fine on other pins when I'm not using the Ethernet shield. I plan to use two thermistors or two one wire temp sensors, and some buttons 
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 1
Posts: 36
...noob...
|
 |
« Reply #6 on: January 05, 2013, 07:16:15 am » |
I would do simple test. first test code for your UNO and LCD for desired pins, than UNO + Ethernet shield with the same code, and without Ethernet cable.
|
|
|
|
|
Logged
|
-- HE3r0 d(R)ive safe
|
|
|
|
Dee Why NSW
Offline
God Member
Karma: 12
Posts: 623
|
 |
« Reply #7 on: January 05, 2013, 08:46:04 am » |
I think he has already done that, and the problem is that both the LCD and the Ethernet want to use pin 4, resulting in some junk on the display. When it that happened to me, I got nothing on the display at all, and eliminating the ethernet lines from the code fixed it.
The problem can be confirmed by connecting a shield by male-to-female loose wires. Looking at my LCD shield, I think it is increasingly clear that it is designed so that this situation can be rectified on-board, using pins 15-19. I guess other LCD shields do the same thing.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 1
Posts: 36
...noob...
|
 |
« Reply #8 on: January 05, 2013, 09:21:09 am » |
I think he has already done that, and the problem is that both the LCD and the Ethernet want to use pin 4, resulting in some junk on the display. When it that happened to me, I got nothing on the display at all, and eliminating the ethernet lines from the code fixed it.
The problem can be confirmed by connecting a shield by male-to-female loose wires. Looking at my LCD shield, I think it is increasingly clear that it is designed so that this situation can be rectified on-board, using pins 15-19. I guess other LCD shields do the same thing.
that is why i suggested stacking hardware and loading code only for UNO +LCD, pins on the Ethernet shield are straight through, so without code for ethernet shield he would be able to confirm that it is not hardware issue (problem with ethernet shield) in the code I've posted earlier everything works without issues on my mega, and lcd goes through ethernet shield. (question is what ethernet shield does he have, there a few different running wild out there)
|
|
|
|
|
Logged
|
-- HE3r0 d(R)ive safe
|
|
|
|
Western New York, USA
Offline
Faraday Member
Karma: 17
Posts: 3507
|
 |
« Reply #9 on: January 05, 2013, 10:25:49 am » |
I think he has already done that, and the problem is that both the LCD and the Ethernet want to use pin 4, resulting in some junk on the display. When it that happened to me, I got nothing on the display at all, and eliminating the ethernet lines from the code fixed it.
The problem can be confirmed by connecting a shield by male-to-female loose wires. Looking at my LCD shield, I think it is increasingly clear that it is designed so that this situation can be rectified on-board, using pins 15-19. I guess other LCD shields do the same thing.
Nick: Your suggestions would be appropriate for someone using a setup like yours but judging from his diagram in reply #4 he does not appear to be using a shield for his LCD.I agree with the approach mentioned by he3r0. Start out with the LCD connected directly to the UNO, using the pins you intend to use in the final implementation. Remove the first and third steps of setup because the LCD initialization, done by lcd.begin(), takes care of both clearing the display and setting the cursor to (0,0). Also, try it out first with a blank loop() and add the loop() code back in if the display works correctly with just the code in setup().
When that is working then remove the wires, insert the ethernet shield, and reconnect the wires. If the display no longer works then you have to figure out which of the pins are not carried up from the UNO to the shield. If it does work then it is time to start adding things back in, one by one, until you find your next problem.Don Edit: You should also verify that your backlight does not require an external series current limiting resistor, most do.
|
|
|
|
« Last Edit: January 05, 2013, 10:28:41 am by floresta »
|
Logged
|
|
|
|
|
Dee Why NSW
Offline
God Member
Karma: 12
Posts: 623
|
 |
« Reply #10 on: January 05, 2013, 11:08:38 am » |
Nick: Your suggestions would be appropriate for someone using a setup like yours but judging from his diagram in reply #4 he does not appear to be using a shield for his LCD.
I am alluding to the OP's situation. The diagram is by somebody else. Maybe the OP doesn't have the LCD on a shield but, if that is the case, I would not have thought he would have had a problem. The diagram is interesting in that it shows the LCD wired to D4, which the OP is already suss about but perhaps Ethernets using D4 to select is not as universal as I thought.
|
|
|
|
|
Logged
|
|
|
|
|
Western New York, USA
Offline
Faraday Member
Karma: 17
Posts: 3507
|
 |
« Reply #11 on: January 05, 2013, 01:28:10 pm » |
The diagram is by somebody else. Sorry I missed that part but I did notice that he didn't mention I2C in the original post.he diagram is interesting in that it shows the LCD wired to D4, which the OP is already suss about I missed that as well. Maybe it's the temperature, I just got back from a nice warm vacation spot. The troubleshooting techniques mentioned previously are still valid.
Don
|
|
|
|
|
Logged
|
|
|
|
|
|