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");
}
}