#include #include #include #include String result = ""; int iPhase = 0; int charCnt = 0; const int switchPin = A5; /* in firefox use view-source:http://weather-broker-cdn.api.bbci.co.uk/en/forecast/rss/3day/2643123 view-source:http://feeds.reuters.com//reuters/UKTopNews view-source:http://feeds.bbci.co.uk/news/rss.xml */ // Enter a MAC address for your controller below. // Newer Ethernet shields have a MAC address printed on a sticker on the shield byte mac[] = { 0xDE, 0xAB, 0xBE, 0xEF, 0xFE, 0xCC }; // The IP address will be dependent on your local network: IPAddress ip(191,11,1,1); //<<< ENTER YOUR IP ADDRESS HERE!!! // use the numeric IP instead of the name for the server: //IPAddress server(74,125,232,128); // numeric IP for Google (no DNS) char server[] = "feeds.reuters.com"; // name address for Google (using DNS) char server2[] = "weather-broker-cdn.api.bbci.co.uk"; // name address for Google (using DNS) String currentChunk = "title"; boolean copyrightPassed = false; String sStory = ""; String sDate = ""; String sDesc = ""; String dateCrib = ""; String dateCribEnd = ""; boolean storyStart = false; boolean storyEnd = false; boolean dateStart = false; boolean dateEnd = false; int iDS, iDE = 0; boolean descStart = false; boolean descEnd = false; boolean cntStatus = false; // Set the static IP address to use if the DHCP fails to assign IPAddress ip(192, 168, 0, 177); // Initialize the Ethernet client library // with the IP address and port of the server // that you want to connect to (port 80 is default for HTTP): EthernetClient client; LiquidCrystal lcd(7,6, 5, 8, 3, 2); // Creates an LC object. Parameters: (rs, enable, d4, d5, d6, d7) int switchState = 0; void setup() { analogWrite(9,40); switchState = analogRead(5); // Serial.begin(9600); lcd.begin(20,4); lcd.setCursor (0,1); if (switchState > 200) { lcd.print(" - News - "); } else { lcd.print(" - Weather - "); lcd.setCursor (0,2); lcd.print(" (Manchester) "); } // while (!Serial) { // wait for serial port to connect. Needed for native USB port only // } // start the Ethernet connection: if (Ethernet.begin(mac) == 0) { // Serial.println("Failed to configure Ethernet using DHCP"); lcd.setCursor (0,2); lcd.print("Failed to configure"); lcd.setCursor (0,3); lcd.print(" Ethernet using DHCP"); // try to congifure using IP address instead of DHCP: Ethernet.begin(mac, ip); } delay(1000); // Serial.println("connecting..."); // lcd.setCursor (0,3); // lcd.print(" Connecting "); // // if you get a connection, report back via serial: if (switchState > 200) { cntStatus = client.connect(server, 80); } else { cntStatus = client.connect(server2, 80); } if (cntStatus) { // lcd.setCursor (0,3); // lcd.print(" Connected "); if (switchState > 200) { // Make a HTTP request: client.println("GET /reuters/UKTopNews HTTP/1.1"); client.println("Host: feeds.reuters.com"); dateCrib = "20 && Story1.substring(0,20) != "BBC Weather - Foreca") { lcd.setCursor (0,0); lcd.print(Story1.substring(0,20)); lcd.setCursor (0,1); lcd.print(Story1.substring(20,40)); lcd.setCursor (0,2); lcd.print(Story1.substring(40,60)); lcd.setCursor (0,3); lcd.print(Story1.substring(60,80)); delay (6000); } sStory = ""; lcd.setCursor (0,0); lcd.print(" "); lcd.setCursor (0,1); lcd.print(" "); lcd.setCursor (0,2); lcd.print(" "); lcd.setCursor (0,3); lcd.print(" "); } } }