PaulS:
I see, so I can loose the F and the two brackets? What is the purpose of it?
Not loose them. Add them. The F() macros causes the literal string to remain in program memory, and enables access to the data from there, rather than allowing it to be copied to SRAM.
Thanks Paul, that's pretty good to know!
Here is what I have a page source
<HTML>
<HEAD>
<style> body { background-color:#303030; }</style>
<TITLE>Home Automation</TITLE>
</HEAD>
<BODY>
<img src='http://www.shedbass.com/dtokez/buttons/hover.png'>
<a href="/?lightAon""><img src='http://www.shedbass.com/dtokez/buttons/on2.png'></a>
</BODY>
</HTML>
Being generated by this
//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//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
//Define light output pins
int LightA = 6;
int LightB = 2;
int LightC = 3;
int LightD = 4;
//For holding pin state data
int LightAState = 0;
int LightBState = 0;
#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(){
//Set up outputs
pinMode(LightA, OUTPUT);
pinMode(LightB, OUTPUT);
pinMode(LightC, OUTPUT);
pinMode(LightD, OUTPUT);
//Start Ethernet
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
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(F("HTTP/1.1 200 OK")); //send new page
client.println("Content-Type: text/html");
client.println();
client.println("<HTML>");
//Write head data
client.println("<HEAD>");
client.println("<style> body { background-color:#303030; }</style>"); //CSS style data
client.println("<TITLE>Home Automation</TITLE>"); //Page title
client.println("</HEAD>");
//Write body data
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>
");
client.println("<img src='http://www.shedbass.com/dtokez/buttons/hover.png'>");
if(LightAState == HIGH)
{
client.println("<a href=\"/?lightAoff\"\"><img src='http://www.shedbass.com/dtokez/buttons/off2.png'></a>
");
}
else if(LightBState == 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 Light A
if(readString.indexOf("?lightAon") >0)//checks for on
{
digitalWrite(LightA, HIGH);
LightAState = HIGH;
Serial.println("Light A On");
}
else if(readString.indexOf("?lightAoff") >0)//checks for off
{
digitalWrite(LightA, LOW);
LightAState = LOW;
Serial.println("Light A Off");
}
///////////////////// control Light B
if(readString.indexOf("?lightBon") >0)//checks for on
{
digitalWrite(LightB, HIGH);
LightBState = HIGH;
Serial.println("Light B On");
}
else if(readString.indexOf("?lightBoff") >0)//checks for off
{
digitalWrite(LightB, LOW);
LightBState = LOW;
Serial.println("Light B Off");
}
//clearing string for next read
readString="";
}
}
}
}
}