Ah! What a silly mistake, I forgot to close the tag as you say ![]()
many thanks!
I'm now attempting to show a different button by reading the state of a pin, but.... its not working lol
Just added this in, but neither image is showing up. When starting up the pin will be low, so I thought that the else if statement would run, which should display the on button, then once on the if loop would run, showing the off button?
maybe I have made another silly error, can't work out
This is the addition:
if(A == HIGH)
     {
      client.println("<a href=\"/?lightAoff\"\"><img src='http://www.shedbass.com/dtokez/buttons/off2.png'></a>");
     }
     else if(A == LOW)
     {
      client.println("<a href=\"/?lightAon\"\"><img src='http://www.shedbass.com/dtokez/buttons/on2.png'></a>
");
     }
//simple button GET server code to control servo and arduino pin 5
//for use with IDE 1.0
//open serial monitor to see what the arduino receives
//use the \ slash to escape the " in the html
//for use with W5100 based ethernet shields
//Powering a servo from the arduino usually DOES NOT WORK.
//note that the below bug fix may be required
//http://www.instructables.com/id/Control-an-LED-over-the-internet-using-the-Arduino/step2/Connected/
// http://code.google.com/p/arduino/issues/detail?id=605
//http://www.instructables.com/id/Arduino-Control-via-a-Web-Service-with-Teleduino/?ALLSTEPS
//http://www.christophercommunications.org/Web_page_based_control.html
int A = 6;
int B = 2;
int C = 3;
int D = 4;
#include <SPI.h>
#include <Ethernet.h>
#include <Servo.h>
Servo myservo;Â // create servo object to control a servo
byte mac[] = {
 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = {
 192, 168, 0, 177 }; // ip in lan
byte gateway[] = {
 192, 168, 0, 1 }; // internet access via router
byte subnet[] = {
 255, 255, 255, 0 }; //subnet mask
EthernetServer server(80); //server port
String readString;
//////////////////////
void setup(){
 pinMode(6, OUTPUT); //pin selected to control
 //start Ethernet
 Ethernet.begin(mac, ip, gateway, subnet);
 server.begin();
 //the pin for the servo co
 //enable serial data print
 Serial.begin(9600);
 Serial.println("server LED test 1.0"); // so I can keep track of what is loaded
}
void loop(){
 // Create a client connection
 EthernetClient client = server.available();
 if (client) {
  while (client.connected()) {
   if (client.available()) {
    char c = client.read();
    //read char by char HTTP request
    if (readString.length() < 100) {
     //store characters to string
     readString += c;
     //Serial.print(c);
    }
    //if HTTP request has ended
    if (c == '\n') {
     ///////////////
     Serial.println(readString); //print to serial monitor for debuging
      client.println("HTTP/1.1 200 OK"); //send new page
     client.println("Content-Type: text/html");
     client.println();
     client.println("<HTML>");
     client.println("<HEAD>");
    Â
     client.println("<style> body { background-color:#d0e4fe; }</style>");
     client.println("<TITLE>Home Automation</TITLE>");
     client.println("</HEAD>");
     client.println("<BODY>");
     //client.println("<H1>Home Automation</H1>");
     //client.println("<hr />");
     client.println("
");
     //Light A
     //client.println("Light A: ");
     //client.println("<a href=\"/?lightAon\"\"><img src='http://www.shedbass.com/dtokez/buttons/on2.png'></a>");
     //client.println("<a href=\"/?lightAoff\"\"><img src='http://www.shedbass.com/dtokez/buttons/off2.png'></a>
");
     if(A == HIGH)
     {
      client.println("<a href=\"/?lightAoff\"\"><img src='http://www.shedbass.com/dtokez/buttons/off2.png'></a>");
     }
     else if(A == LOW)
     {
      client.println("<a href=\"/?lightAon\"\"><img src='http://www.shedbass.com/dtokez/buttons/on2.png'></a>
");
     }
     //Light B
     client.println("<a href=\"/?lightBon\"\">Turn On Light B</a>");
     client.println("<a href=\"/?lightBoff\"\">Turn Off Light B</a>
");Â Â Â
     client.println("</BODY>");
     client.println("</HTML>");
     delay(1);
     //stopping client
     client.stop();
     ///////////////////// control arduino Light A
     if(readString.indexOf("?lightAon") >0)//checks for on
     {
      digitalWrite(A, HIGH);
      Serial.println("Light A On");
     }
     else{
      if(readString.indexOf("?lightAoff") >0)//checks for off
      {
       digitalWrite(A, LOW);
       Serial.println("Light A Off");
      }
     }
     ///////////////////// control arduino Light B
     if(readString.indexOf("?lightBon") >0)//checks for on
     {
      digitalWrite(B, HIGH);
      Serial.println("Light B On");
     }
     else{
      if(readString.indexOf("?lightBoff") >0)//checks for off
      {
       digitalWrite(B, LOW);
       Serial.println("Light B Off");
      }
     }
     //clearing string for next read
     readString="";
    }
   }
  }
 }
}