#include <EEPROM.h>


char password[7];

int index = -1;


void writepassword() {
  Serial.print ("pw letta: ");
  Serial.println(password);
  EEPROM.put(0,password);

}

void readpassword(){

char pippo[7];
 EEPROM.get(0,pippo);
 Serial.print ("pw letta da eprom: ");
  Serial.println(pippo);

}

void setup() {
  Serial.begin(9600);
  Serial.print("test");
  
  }
void loop() {
  if ( Serial.available()) {
    char ch = Serial.read();
    if ( ch >= '0' && ch <= '9') {
      index ++;
      password[index] = ch;
      if (index == 5) {
        password[index + 1] = 0;
        Serial.println();
        writepassword();
        //Serial.print (ch);
        index = -1;
      }
   
    }
  
    if ( ch == 'p') {
       
       readpassword();
    }
  }
}