Pages: 1 [2] 3   Go Down
Author Topic: Ethernet & LCD Shield project  (Read 1758 times)
0 Members and 1 Guest are viewing this topic.
Wales, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, and no joy.

I'll rephrase - all pins from the arduino run into the ethernet shield, all pins except Digital 4 and 10 run from the Ethernet to the LCD.
Digital pins 3 and 4 on the LCD are connected.
« Last Edit: May 22, 2012, 03:56:21 pm by Rirawen » Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 140
Posts: 5870
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't understand that. If you remove the ethernet shield and connect the LCD shield directly to the Arduino with the LCD shield pins still bent and the jumper, does the LCD work?

add: If that doesn't work, remove the jumper and bend pin 4 back to connect to the Arduino. Check the LCD again. And change this back to pin 4
Code:
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
« Last Edit: May 22, 2012, 04:08:00 pm by SurferTim » Logged

Wales, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a blacklight, but no output on the LCD.

Trace on serial shows;
Quote
Starting ethernet...started
Connecting...
failed
..repeatedly.
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 140
Posts: 5870
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There will be no ethernet connection because there is no ethernet shield.

Remove the jumper wire and rebend pin 4 so it inserts in the Arduino and change this back to pin 4:
Code:
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

That almost has to work, doesn't it?
Logged

Wales, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, that works.

..and just for reference the code; (just incase I did something stupid)
Code:
#include <SPI.h>
#include <Ethernet.h>
#include <LiquidCrystal.h>

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,50);

IPAddress server(192,168,0,90);
EthernetClient client;

void setup() {
 
  Serial.begin(9600);
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);
 
  LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

  lcd.begin(16, 2);
  lcd.setCursor(0,0);
  lcd.print("Web Client:");

  Serial.print("Starting ethernet...");
  Ethernet.begin(mac,ip);
  Serial.println("started");
  delay(2000);

  Serial.println("Connecting...");

  if (client.connect(server, 80)) {
    Serial.println("Connected");
    client.println("GET / HTTP/1.0");
    client.println();

    while(client.connected()) {
      while(client.available()) {
        Serial.write(client.read());
      }
    }
    client.stop();
    Serial.println("disconnected");
  }
  else {
    Serial.println("failed");
  }
}

void loop() {
  delay(2000);
  setup();
}
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 140
Posts: 5870
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would do it this way. Set up the ethernet interface once, then make the connection in the loop().
Code:
#include <SPI.h>
#include <Ethernet.h>
#include <LiquidCrystal.h>

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,50);

IPAddress server(192,168,0,90);
EthernetClient client;

void setup() {
  
  Serial.begin(9600);
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);
  
  LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

  lcd.begin(16, 2);
  lcd.setCursor(0,0);
  lcd.print("Web Client:");

  Serial.print("Starting ethernet...");
  Ethernet.begin(mac,ip);
  Serial.println("started");
  delay(2000);

}

void loop() {
 
  lcd.clear();
  lcd.print("Connecting");

  Serial.println("Connecting...");

  if (client.connect(server, 80)) {
    Serial.println("Connected");
    client.println("GET / HTTP/1.0");
    client.println();

    while(client.connected()) {
      while(client.available()) {
        Serial.write(client.read());
      }
    }
    client.stop();
    Serial.println("disconnected");
  }
  else {
    Serial.println("failed");
  }

  lcd.clear();
  lcd.print("Disconnected");

 delay(2000);
}

Add any cursor position changes to that it may need. edit: I added a "lcd.clear()" to each print.

Does this change the LCD display as it goes through the loop? It will not make a connection yet. Leave the shield off. Best to do this one shield at a time.
« Last Edit: May 22, 2012, 04:27:23 pm by SurferTim » Logged

Wales, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, I get the initial "Web Client:" then it writes the connecting / disconnected lines over and over.

add: though i notice you have a clear() in there.. the LCD does not clear, it just continues from where the cursor stopped.
« Last Edit: May 22, 2012, 04:30:19 pm by Rirawen » Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 140
Posts: 5870
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Now bend digital 4 so it does not insert into the Arduino, and put the jumper on the shield from 4 to 3.

Change to this again:
Code:
LiquidCrystal lcd(8, 9, 3, 5, 6, 7);

Still no LCD output?
Logged

Wales, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Changed, pin 4 removed from the arduino, jumper between 3 and 4 on the LCD - no joy.. code runs i can see on the serial monitor.
But no text on the LCD.
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 140
Posts: 5870
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I only have one more try left, then we are out of pins. Try digital 2 instead of digital 3. Move the jumper one pin over, connecting digital 4 to digital 2 , and change to this:
Code:
LiquidCrystal lcd(8, 9, 2, 5, 6, 7);

If that doesn't do it, I have run out of pins and ideas at the same time.  smiley-sad

edit: I lied. I have one more idea.
Bend digital 4 on the LCD shield so it does not connect to the ethernet shield.
Bend digital pin 4 on the ethernet shield so it does not connect to digital pin 4 on the Arduino.
Put the jumper from digital 4 on the LCD shield to the Arduino digital 4.
Put another jumper from the ethernet shield digital 4 to +5v.
Then back to this:
Code:
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

But that is it for my ideas. With that setup, the microSD card is not useable. You might be able to jumper that pin on the ethernet shield to digital 3.
« Last Edit: May 22, 2012, 05:11:59 pm by SurferTim » Logged

Wales, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your help Tim,

It's late and I'm going to pack it in for tonight.

One thing I have notice.. on the LCD Shield where the digital pins are.. their neighboring counterparts are not connected.
This is an almost identical board to the LCD board im using, only visual difference is the drive the future logo, which is not present on my board.


I noticed that using pin 4 and connecting from 4 on the arduino to the outer 4 on the LCD board did not produce an output, but connecting 4 on the
arduino board to pin 4 on the factory header with no code changes - works.. smiley-confuse

I will have to wait until morning before I can dig my tester out the garage and confirm this, but it looks like I'm skuppered  smiley-sad
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 140
Posts: 5870
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm packing it in for tonight also.

The "outer 4" is the digital 4 in the red rectangle, and the "factory header" is in the blue rectangle? And you think they may not be connected? And if you use digital 4 in the blue, it works?
Logged

Wales, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The "outer 4" is the digital 4 in the red rectangle, and the "factory header" is in the blue rectangle? And you think they may not be connected? And if you use digital 4 in the blue, it works?
Yes.. I had assumed from previous shields that each pin red to blue were connected, but apparently not.
I'm also getting that dimming of the LCD characters again.

Add:
OK I've had a little success smiley

I have both the Ethernet and LCD shields connected, I'm getting a good response from the webserver which is feeding through in the serial monitor,
and I'm getting output (if a bit dim as described above) on the LCD..

I changed the code ever so slightly, no pin changes.. just to structure the LCD output so it didn't just keep overwriting the last string of chars.

here it is;
Code:
#include <SPI.h>
#include <Ethernet.h>
#include <LiquidCrystal.h>

byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,50);

IPAddress server(192,168,0,90);
EthernetClient client;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
  
void setup() {
  
  Serial.begin(9600);
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);
  
  lcd.begin(16, 2);
  lcd.setCursor(0,0);
  lcd.print("Web Client:");

  Serial.print("Starting ethernet...");
  Ethernet.begin(mac,ip);
  Serial.println("started");
  delay(2000);

}

void loop() {
  
  lcd.setCursor(0,1);
  lcd.print("Connecting...   ");
  Serial.println("Connecting...");

  delay(1000);

  if (client.connect(server, 80)) {
    
    lcd.setCursor(0,1);
    lcd.print("Connected       ");
    
    Serial.println("Connected to server.");
    client.println("GET / HTTP/1.0");
    client.println();

    while(client.connected()) {
      while(client.available()) {
        Serial.write(client.read());
      }
    }
    
    delay(3000);
    
    client.stop();
    Serial.println("Disconnected from server.");
  }
  else {
    Serial.println("Connection to server Failed.");
  }
  
  
  lcd.setCursor(0,1);
  lcd.print("Disconnected    ");

 delay(2000);
}

Add also: Digital Pin 4 is connected to all boards and pin 10 on the LCD board is not connected to anything.
« Last Edit: May 23, 2012, 04:24:16 am by Rirawen » Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 140
Posts: 5870
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are both shields powered by the Arduino +5v? Maybe not enough power? My first check would be the voltage on the +5v pin.

edit: Personally, I do my best to keep devices available. I would try to move digital pin 4 on the LCD to digital 3 and use that pin instead. Then I could use the microSD card. Otherwise, the best storage for large amounts of data is not available.
« Last Edit: May 23, 2012, 05:41:46 am by SurferTim » Logged

Wales, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, both are stacked directly with the Arduino and powered through the USB.
Adding a 9v battery to the power socket does seem to rectify the dimming, but only a little.

My multimeter shows the +5v pin at +4.4v without the battery and +4.7v (though I think the battery is on it's way out anyway..
Will have to either knock together a mains supply or buy one if I don't have the parts, and test running only on the mains supply.
Logged

Pages: 1 [2] 3   Go Up
Jump to: