Code problem

I'm would like to use LCD in "RSS Weather Reader", Project 50 in "Beginning Arduino" book instead of Serial terminal. Here is sketch so far.
LCD will not print "connected", even though ethernet shield does connect and I get weather. I see good print on LCD for the 3 prior lcd.print statements. Even, if I unplug LAN, I don't see "connection fail" either. It seems when I enter ethernet section, LCD does not print. Original sketch using serial.print works fine.

#include <Ethernet.h>
#include <SPI.h>
#include <LiquidCrystal.h>

// Initialize
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// Max string length may have to be adjusted depending on data to be extracted
#define MAX_STRING_LEN 20

// Setup vars
char tagStr[MAX_STRING_LEN] = "";
char dataStr[MAX_STRING_LEN] = "";
char tmpStr[MAX_STRING_LEN] = "";
char endTag[3] = {'<', '/', '\0'};
int len;
// Flags to differentiate XML tags from document elements (ie. data)
boolean tagFlag = false;
boolean dataFlag = false;

// Ethernet vars
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {192, 168, 0, 104};
byte server[] = { 140, 90, 113, 200 }; // www.weather.gov

// Start ethernet client
Client client(server, 80);

void setup()
{
lcd.begin(16, 2); // 16 columns, 2 rows
Serial.begin(9600);
lcd.clear();
lcd.print("RSS WX Feed");
lcd.setCursor(0,1);
lcd.print("Start WX Reader");
delay(3000);
lcd.clear();
lcd.print("connecting...");
delay(1000);
Ethernet.begin(mac, ip);
delay(1000);
lcd.setCursor(0,1);

if (client.connect()) {
lcd.print("connected");
client.println("GET /xml/current_obs/KEDW.xml HTTP/1.0");
client.println();
delay(2000);
} else {
lcd.clear();
lcd.print("connection fail");
}
}

Do you know which pins the ethernet shield uses? If it's an official ethernet shield, look here http://arduino.cc/en/Main/ArduinoEthernetShield if you don't know.

Now, which pins that the ethernet shield uses are you also trying to use for the LCD?

Now, do you understand why the LCD quits working?

You can not use pin 4 for lcd as it is used for the ethernet shield...

You can't use 11 or 12, either.

yes, I'm using Mega so for I missed it.

OK, I understand now. So, what would be a valid selection of pins to use in this application?

use all the pin you want except the one that will not work...

So for your lcd, try with 22, 24, 26, 28, 30, 32 (contigous one on the side). Every will be ok after that.

I don't understand. I'm using a Arduino Uno. I doesn't have those high numbered pins. The LCD pins are numbered 1-16.

I'm using a Arduino Uno... The LCD pins are numbered 1-16.

1 to 16? Really?

You can use any pins that are not already in use. The ethernet shield uses pins 4, 10, 11, 12, and 13. The serial port uses pins 0 and 1. That leaves you with 2, 3, 5, 6, 7, 8, and 9, unless you are using them for something else. If you run out of digital pins, remember that the analog pins can be used as digital pins, numbered 14 to 19.

PaulS

Your answer was the clearest yet. I'm now using 2, 3, 5, 6, 7, 8. Was using 2, 3, 4, 5, 11, 12. Not good with LCD! WX reader now works up to this point. I finally see "connected" on LCD. I see 61 (degrees) from Edwards. More code to add to complete. I should have looked at the E Shield more closely.

Thanks again, Don