Pages: [1]   Go Down
Author Topic: Problem with LCD + Ethernet Shield  (Read 1306 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Edison Member
*
Karma: 49
Posts: 1619
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

Dee Why NSW
Offline Offline
Full Member
***
Karma: 5
Posts: 206
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Faraday Member
**
Karma: 46
Posts: 2883
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Offline Offline
Newbie
*
Karma: 2
Posts: 39
...noob...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

that's what I did when i was testing my Ethernet shield wit my Mega 2560
Code:
/*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 Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 2
Posts: 39
...noob...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Edison Member
*
Karma: 47
Posts: 2260
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Newbie
*
Karma: 2
Posts: 39
...noob...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Faraday Member
**
Karma: 35
Posts: 4299
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Edison Member
*
Karma: 47
Posts: 2260
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Offline
Faraday Member
**
Karma: 35
Posts: 4299
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Quote
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

Pages: [1]   Go Up
Jump to: