Modifica EEPROM Secret-Knock-Detecting-Door-Lock

Salve ho provato a modificare il programma preso da http://www.instructables.com/id/Secret-Knock-Detecting-Door-Lock/ per aprire la serratura bussando. Ho fatto giusto secondo voi le modifiche del programma per salvare la programmazione delle bussate e non perderla ogni volta che resetto? le modifiche sono le seguenti.! Ho inserito delle faccine verdi dove ho fatto modifiche per la EEPROM. Non credo di aver fatto giusto sia nella sintassi sia nella scelta delle variabile.è la prima volta che uso questa funzione. ringrazio. (il programma completo originale è questo http://www.instructables.com/files/orig/F1T/DII6/GIYWWK6R/F1TDII6GIYWWK6R.tmp)

#include <EEPROM.h  :grin:

void setup() {
  
  pinMode(lockMotor, OUTPUT);
  pinMode(redLED, OUTPUT);
  pinMode(greenLED, OUTPUT);
  pinMode(programSwitch, INPUT);
  for (int i = 0; i < 512; i++)                             :grin:
  secretCode [i]= EEPROM.read(i);                    :grin:
  Serial.begin(9600);               			// Uncomment the Serial.bla lines for debugging.
  Serial.println("Program start.");  			// but feel free to comment them out after it's working right.
  
  digitalWrite(greenLED, HIGH);      // Green LED on, everything is go.
}




boolean validateKnock(){
  int i=0;
 
  // simplest check first: Did we get the right number of knocks?
  int currentKnockCount = 0;
  int secretKnockCount = 0;
  int maxKnockInterval = 0;          			// We use this later to normalize the times.
  
  for (i=0;i<maximumKnocks;i++){
    if (knockReadings[i] > 0){
      currentKnockCount++;
    }
    if (secretCode[i] > 0){  					//todo: precalculate this.
      secretKnockCount++;
    }
    
    if (knockReadings[i] > maxKnockInterval){ 	// collect normalization data while we're looping.
      maxKnockInterval = knockReadings[i];
    }
  }
  
  // If we're recording a new knock, save the info and get out of here.
  if (programButtonPressed==true){
      for (i=0;i<maximumKnocks;i++){ // normalize the times
        secretCode[i]= map(knockReadings[i],0, maxKnockInterval, 0, 100);
        EEPROM.write(i,secretCode[i]);                                                   :grin:
      }
      // And flash the lights in the recorded pattern to let us know it's been programmed.
      digitalWrite(greenLED, LOW);
      digitalWrite(redLED, LOW);
      delay(1000);
      digitalWrite(greenLED, HIGH);
      digitalWrite(redLED, HIGH);
      delay(50);
      for (i = 0; i < maximumKnocks ; i++){
        digitalWrite(greenLED, LOW);
        digitalWrite(redLED, LOW);  
        // only turn it on if there's a delay
        if (secretCode[i] > 0){                                   
          delay( map(secretCode[i],0, 100, 0, maxKnockInterval)); // Expand the time back out to what it was.  Roughly. 
          digitalWrite(greenLED, HIGH);
          digitalWrite(redLED, HIGH);
        }
        delay(50);
      }
	  return false; 	// We don't unlock the door when we are recording a new knock.
  }
  
  if (currentKnockCount != secretKnockCount){
    return false; 
  }

Non occorre aprire una nuova discussione per continuare a trattare il problema che mi sembra correlato a questo thread:
http://forum.arduino.cc/index.php?topic=185960.0