I am using the ethernet shield to connect to my server. Everything works fine except that if the information updates on the server than it is not updated in arduino. Is there something that could be done?
#include <Ethernet.h>
byte mac[] = { 02, 00, 00, 00, 00, 01 };
byte ip[] = { 85, 225, 87, 124};
byte server[] = { 69, 89, 22, 133 }; // Google
byte gateway[] = { 85, 225, 84, 1 };
byte subnet[] = { 255, 225, 252, 0 };
Client client(server, 80);
void setup()
{
Ethernet.begin(mac, ip, gateway, subnet);
Serial.begin(9600);
delay(1000);
// initialize the LED pins:
for (int thisPin = 2; thisPin < 7; thisPin++) {
pinMode(thisPin, OUTPUT);
}
Serial.println("connecting...");
if (client.connect()) {
Serial.println("connected");
client.print("GET /~cameron5/test_etherent.html");
client.println();
} else {
Serial.println("connection failed");
}
}
void loop()
{
if (client.available()) {
int inByte = client.read();
// do something different depending on the character received.
// The switch statement expects single number values for each case;
// in this exmaple, though, you're using single quotes to tell
// the controller to get the ASCII value for the character. For
// example 'a' = 97, 'b' = 98, and so forth:
switch (inByte) {
case 'a':
digitalWrite(2, HIGH);
break;
case 'b':
digitalWrite(3, HIGH);
break;
case 'c':
digitalWrite(4, HIGH);
break;
case 'd':
digitalWrite(5, HIGH);
break;
case 'e':
digitalWrite(6, HIGH);
break;
default:
// turn all the LEDs off:
for (int thisPin = 2; thisPin < 7; thisPin++) {
digitalWrite(thisPin, LOW);
}
}
char c = client.read();
Serial.print(c);
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;;)
;
}
}