sorry the code is:
#include <Ethernet.h>
#include <SPI.h>
/*
Simple Ethernet Test
Arduino server outputs simple text to browser
The circuit:
* Arduino Duemilanove
* Arduino Ethernet shield
* Basic FTDI breakout 5V
*LED connected to GND and digital pin 4 via resistor
By Minde
http://www.sciencprog.com/
*/
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x49, 0xD6 };
byte ip[] = {192,168,1,70}; // IP address of WiShield
byte gateway[] = {192,168,1,254}; // router or gateway IP address
byte subnet[] = {255,255,255,0};
Server server(6969); //server port
int ledPin = 4; // LED pin
int LEDpin = 7;
String state = String(3);
word Adc = 0;
String readString = String(30); //string for fetching data from address
boolean LEDON = false; //LED status flag
void Pasword();
void Portada();
void setup(){
//start Ethernet
Ethernet.begin(mac, ip, gateway, subnet);
//Set pin 4 to output
pinMode(LEDpin,OUTPUT);
digitalWrite(LEDpin,LOW);
state = "OFF";
String state = String(3);
//enable serial datada print
Serial.begin(9600);
}
void loop(){
// Create a client connection
Client client = server.available();
if (client) {
while (client.connected()){
char c = client.read();
if (readString.length() < 30){
readString += c;
}
Serial.print(c);
if (c == '\n') {
if(readString.trim() == ("GET /?C=1678 HTTP/1.1")){
//client.println("<h1>Clave Ok</h1>");
Portada();
}else{
//client.println("<h1>Clave Erronea</h1>");
}
//client.println("HTTP/1.1 200 OK");
//client.println("Content-Type: text/html");
client.println();
client.print("<body style=background-color:#ffffff>");
client.println("<h1>Control de Acceso</h1>");
client.println("<form method=get name=LED>");
client.println("<input type=""password"" name=C>");
client.println("<input type=submit value=submit></form>");
//clearing string for next read
readString="";
//stopping client
client.stop();
}
}
}
}
void Portada(){
while(1){
// Create a client connection
Client client = server.available();
if (client) {
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (readString.length() < 30) {
readString.concat(c);
}
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
int LED = readString.indexOf("LED=");
if (readString.substring(LED,LED+5) == "LED=T") {
digitalWrite(LEDpin,HIGH);
state = "ON";
}
else if (readString.substring(LED,LED+5) == "LED=F") {
digitalWrite(LEDpin,LOW);
state = "OFF";
}
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("<form method=get name=form>");
client.println("<img src='http://dl.dropbox.com/u/6916111/tvoff.png' style=\"position:fixed;left:68px;top:80px;width:636px;height:431px;z-index:1;padding:0;\">");
if (state == "ON") {
// client.print("TESTE ");
client.println("<img src='http://dl.dropbox.com/u/6916111/tvon.png' type='image' style=\"position:fixed;left:254px;top:146px;width:146px;height:93px;z-index:2;padding:0;\">");
client.println("<a href=\"./?LED=F\" src='http://dl.dropbox.com/u/6916111/off.png' type='image' style=\"position:fixed;left:254px;top:146px;width:146px;height:93px;z-index:2;padding:0;\">");
}
else {
client.println("<img src='http://dl.dropbox.com/u/6916111/off.png' type='image' style=\"position:fixed;left:254px;top:146px;width:146px;height:93px;z-index:2;padding:0;\">");
client.println("<a href=\"./?LED=T\" src='http://dl.dropbox.com/u/6916111/tvon.png' type='image' style=\"position:fixed;left:254px;top:146px;width:146px;height:93px;z-index:2;padding:0;\">");
}
//client.print("LED is ");
// client.print(state);
client.print("
");
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
readString = "";
// close the connection:
client.stop();
}
}
}
void Pasword();