     }
     // save the current output state on EEPROM every 10 seconds
     if(millis()-lastTime>10000){
-      for(int i=0;i<numPin;i++){
+      for(int i=0;i<numOutPin;i++){
         int address = i/8;
         byte pos = i%8;
         if(digitalRead(output_pins[i])==HIGH){


String getOutputStatusJSON(){
    String array="[";
  for(int i=0;i<numPin;i++)
   { 
    if(digitalRead(output_pins[i])==HIGH)
      array+="1";
    else
      array+="0"; 
    if(i!=(numPin-1))
      array+=",";
   }
   array+="]";

 */
String getVettoreStato(){
  String arrayStato = "";
  for(int i=0;i<numInPin;i++)
   {
    if(digitalRead(input_pins[i])==HIGH) 
      arrayStato+="1";
    else 
      arrayStato+="0";
    if(i!=(numInPin-1))
      arrayStato+=",";
   }
   return arrayStato;
