I want to adjust the background color of a web page by adjusting a pot, but I can't for the life of me figure out why I'm not able to connect to the web server. I just get "Unable to connect to server" in my browser. Here's the code, help point me towards anything missing or that needs revision please.
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x50, 0x9A };
byte ip[] = { 10, 0, 1, 8 };
EthernetServer server(8010);
void setup() {
pinMode(A3, INPUT);
Serial.begin(9600);
Ethernet.begin(mac, ip);
server.begin();
}
void loop() {
EthernetClient client = server.available();
int val = analogRead(A3); //read pot analog input
if (client) {
boolean current_line_is_blank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
int color = map(val, 0, 1023, 0x000000, 0xFFFFFF); //map the analogRead() values to HEX values for HTML colors
Serial.println(val); //print em'
Serial.println(color);
Serial.println();
if (c == '\n' && current_line_is_blank) {
client.println("HTTP/1.1 200 OK"); //standard HTTP header, a little HTML too
client.println("Content-Type: text/html");
client.println();
client.println("<html><head><title>");
client.println("Change pot to change color!");
client.println("</title><body bgcolor=");
client.print(color);
client.println(">");
client.println("<h1>Hello, World</h1>");
client.println();
client.print("</body></html>");
}
if (c == '\n') {
current_line_is_blank = true;
} else if (c != '\r') {
current_line_is_blank = false;
}
}
}
delay(1);
client.stop();
}
}