 
 String request;
 
+long lastTime;
+
 void setup() {
-  Serial.begin(9600);
   for(int i=0;i<numPin;i++){
     pinMode(output_pins[i],OUTPUT);
     pinMode(input_pins[i],INPUT);
+    //load the last output state
+    int address = i/8;  
+    byte pos = i%8;
+    bool value = mem.readBit(address, pos);
+    if(value==1){
+      digitalWrite(output_pins[i], HIGH);  
+    }
+    else{
+      digitalWrite(output_pins[i], LOW);  
+    }
   }
   
+  pinMode(4, OUTPUT);  //pin SDcard on EthernetShield  
+  digitalWrite(4, HIGH);
   pinMode(10, OUTPUT); //pin ETHCS
   digitalWrite(10,HIGH); //impostiamo il pin ETHCS al valore alto per evitare problemi al caricamento della pagina
   
+  lastTime=0;
+
   Ethernet.begin(mac, ip);
   server.begin();
   // give the Ethernet shield a second to initialize:

        }
      }
    }
    // give the web browser time to receive the data
    delay(10);
}



#include <Ethernet.h>
#include <EthernetClient.h>
#include <EthernetServer.h>
#include <SPI.h>
#include <EEPROMex.h>
#include <EEPROMVar.h>

//used to save the output state: 1 bit for output pin
EEPROMClassEx mem;

//number of pins used (equals for input and output)
#define numPin 
byte output_pins[] = {}; //insert array output pin es.{2,3,4,5,6,7}
byte input_pins[] = {}; // insert array input pin es.{14,15,16,17,18,19}

byte mac[]={}; //insert MAC
String my_mac=""; //insert MAC as String es. "90-A2-DA-10-21-A9"


IPAddress ip();  //insert ip for this shield
