//Ethernet Switch
//
//Intro:
//This will swich on and off outputs trough your mobile device.
//No images or links to images. CSS3 and HTML5 use.
//Though it work with other web browser, we suggest Safari for best experiance.
//
//Version: Web Server Ethernet Switching Version 3.05
//Author: Claudio Vella - Malta
//Initial code from: http://bildr.org/2011/06/arduino-ethernet-pin-control/
//Made lot of comments for beginners.
//ARDUINO 1.0+ ONLY
# Include
# Include
////////////////////////////////////////////////////////////////////////
//CONFIGURE
////////////////////////////////////////////////////////////////////////
//IP manual settings
byte ip[] = { 192, 168, 0, 177 }; //Manual setup only
byte gateway[] = { 192, 168, 0, 254 }; //Manual setup only
byte subnet[] = { 255, 255, 255, 0 }; //Manual setup only
// if need to change the MAC address (Very Rare)
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//Ethernet Port
EthernetServer server = EthernetServer(80); //default html port 80
//The number of outputs going to be switched.
int outputQuantity = 8; //when added to outputLowest result should not exceed 10
//The lowest output pin we are starting from
int outputLowest = 2; //Should be between 2 to 9
////////////////////////////////////////////////////////////////////////
// Variable declaration
int outp = 0;
boolean printLastCommandOnce = false;
boolean printButtonMenuOnce = false;
boolean initialPrint = true;
String allOn = "";
String allOff = "";
boolean reading = false;
boolean readInput[10]; //Create a boolean array for the maximum ammount.
//Beginning of the program
void setup(){
Serial.begin(9600);
//Pins 10,11,12 & 13 are used by the ethernet shield
//Set pins as Outputs
for (int var = outputLowest; var < outputLowest + outputQuantity; var++) {
pinMode(var, OUTPUT);
}
digitalWrite(9, HIGH);//allume la sortie 9 au depart
//Setting up the IP address. Comment out the one you dont need.
//Ethernet.begin(mac); //for DHCP address. (Address will be printed to serial.)
Ethernet.begin(mac, ip, gateway, subnet); //for manual setup. (Address is the one configured above.)
server.begin();
Serial.println(Ethernet.localIP());
}
void loop(){
// listen for incoming clients, and process requests.
checkForClient();
}
void checkForClient(){
EthernetClient client = server.available();
if (client) {
// an http request ends with a blank line
boolean currentLineIsBlank = true;
boolean sentHeader = false;
while (client.connected()) {
if (client.available()) {
if(!sentHeader){
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connnection: close");
client.println();
client.println("");
client.println("");
// add page title
client.println("Telecommande Ethernet");
client.println("");
// add a meta refresh tag, so the browser pulls again every 5 seconds:
client.println("");
// add other browser configuration
client.println("");
client.println("");
client.println("");
//
//-------- debut de la page HTML -------
client.println("
");//
client.print("[[Fichier:),client.print(]]") ; // " >
client.println("
");//
//-------- fin de la page HTML -------
//
//-------- debut de la page HTML -------
// client.println("
");//
// client.print("[[Fichier:),client.print(]]") ; // " >
//client.println("
");//
//-------- fin de la page HTML -------
//inserting the styles data, usually found in CSS files.
client.println("");
client.println("");
//now printing the page itself
client.println("");
client.println("