Voila mon code
// pins
#include "etherShield.h"
#include "ETHER_28J60.h"
#include <avr/pgmspace.h> //bibliothèque nécessaire au stockage d'informations dans la mémoire du circuit
int relay1 = 2;
int relay2 = 3;
int relay3 = 4;
int relay4 = 5;
boolean r1 = true;
boolean r2 = true;
boolean r3 = true;
boolean r4 = true;
// On définit ici nos chaines de caractères afin de pouvoir les enregistrer dans la mémoire
prog_char string_0[] PROGMEM = "<!DOCTYPE HTML> \r \n";
prog_char string_1[] PROGMEM = "<html>\r \n";
prog_char string_2[] PROGMEM = "<title>Relays over internet</title>\r \n";
prog_char string_3[] PROGMEM = "<body bgcolor=black>\r \n";
prog_char string_4[] PROGMEM = "<font color=white>\r \n";
prog_char string_5[] PROGMEM = "<center>\r \n";
prog_char string_6[] PROGMEM = "<b>You can make your choice among the different plugs available!</b>
\r \n";
prog_char string_7[] PROGMEM = "<FORM><INPUT type=button style=\"background-color:#3cb371\" value=Switch1 onClick=window.location='/?cmd1\'></FORM>\r \n";
prog_char string_8[] PROGMEM = "<FORM><INPUT type=button style=\"background-color:#E30000\" value=Switch1 onClick=window.location='/?cmd1\'></FORM>\r \n";
prog_char string_9[] PROGMEM = "<FORM><INPUT type=button style=\"background-color:#3cb371\" value=Switch2 onClick=window.location='/?cmd2\'></FORM>\r \n";
prog_char string_10[] PROGMEM = "<FORM><INPUT type=button style=\"background-color:#E30000\" value=Switch2 onClick=window.location='/?cmd2\'></FORM>\r \n";
prog_char string_11[] PROGMEM = "<FORM><INPUT type=button style=\"background-color:#3cb371\" value=Switch3 onClick=window.location='/?cmd3\'></FORM>\r \n";
prog_char string_12[] PROGMEM = "<FORM><INPUT type=button style=\"background-color:#E30000\" value=Switch3 onClick=window.location='/?cmd3\'></FORM>\r \n";
prog_char string_13[] PROGMEM = "<FORM><INPUT type=button style=\"background-color:#3cb371\" value=Switch4 onClick=window.location='/?cmd4\'></FORM>\r \n";
prog_char string_14[] PROGMEM = "<FORM><INPUT type=button style=\"background-color:#E30000\" value=Switch4 onClick=window.location='/?cmd4\'></FORM>\r \n";
prog_char string_15[] PROGMEM = "</html>";
// A présent, définir un tableau pour accéder aux chaînes
PROGMEM const char *string_table[] ={ //création d'un tableau appelé string_table
string_0, string_1, string_2, string_3, string_4, string_5, string_6, string_7, string_8, string_9, string_10, string_11};
char buffer[130]; // On définit un buffer qui fait la taille de la plus grande chaine de caractères arrondie à la dixaine supérieure afin de ne pas déborder
//TCP/IP SETTINGS ---------------------------------------------------------------------------------------------------------
static uint8_t mac[6] = {0x54, 0x55, 0x58, 0x10, 0x00, 0x3A}; // this just needs to be unique for your network,
// so unless you have more than one of these boards
// connected, you should be fine with this value.
static uint8_t ip[4] = {192, 168, 1, 15}; // the IP address for your board. Check your home hub
// to find an IP address not in use and pick that
// this or 10.0.0.15 are likely formats for an address
// that will work.
static uint16_t port = 80; // Use port 80 - the standard for HTTP
//-------------------------------------------------------------------------------------------------------------------------
ETHER_28J60 e;
void setup()
{
e.setup(mac, ip, port);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(relay4, OUTPUT);
digitalWrite(relay1, r1);
digitalWrite(relay2, r2);
digitalWrite(relay3, r3);
digitalWrite(relay4, r4);
Serial.begin(9600);
Serial.println("Communication etablie arduinoRelay v1");
}
void loop()
{
char* params;
if (params = e.serviceRequest())
{
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[0])));
e.print(buffer);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[1])));
e.print(buffer);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[2])));
e.print(buffer);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[3])));
e.print(buffer);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[4])));
e.print(buffer);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[5])));
e.print(buffer);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[6])));
e.print(buffer);
if ( r1 == true){
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[7])));
e.print(buffer);
}else{
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[8])));
e.print(buffer);
}
if ( r2 == true){
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[9])));
e.print(buffer);
}else{
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[10])));
e.print(buffer);
}
if ( r3 == true){
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[11])));
e.print(buffer);
}else{
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[12])));
e.print(buffer);
}
if ( r1 == true){
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[13])));
e.print(buffer);
}else{
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[14])));
e.print(buffer);
}
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[15])));
e.print(buffer);
Serial.print("END");
if (strcmp(params, "?cmd1") == 0)
{
r1 = !r1;
digitalWrite(relay1, r1);
}
else if (strcmp(params, "?cmd2") == 0)
{
r2 = !r2;
digitalWrite(relay2, r2);
}
else if (strcmp(params, "?cmd3") == 0)
{
r3 = !r3;
digitalWrite(relay3, r3);
}
else if (strcmp(params, "?cmd4") == 0)
{
r4 = !r4;
digitalWrite(relay4, r4);
}
else if (strcmp(params, "?invert") == 0){
r1 = !r1; r2 = !r2; r3 = !r3; r4 = !r4;
digitalWrite(relay1, r1);
digitalWrite(relay2, r2);
digitalWrite(relay3, r3);
digitalWrite(relay4, r4);
}
if (strcmp(params, "?allOff") == 0){
if ( r1 == false){ r1 = !r1;}
if ( r2 == false){ r2 = !r2;}
if ( r3 == false){ r3 = !r3;}
if ( r4 == false){ r4 = !r4;}
digitalWrite(relay1, r1);
digitalWrite(relay2, r2);
digitalWrite(relay3, r3);
digitalWrite(relay4, r4);
}
e.respond();
}
}