Question using EEPROM

Discussion in 'Programmer's Corner' started by brian25, Aug 14, 2013.

  1. brian25

    Thread Starter Member

    May 13, 2013
    37
    0
    How to save the password in eeprom? when the device is turn off the pass was still in the chip.
    and what syntax to use for changing the password?


    tnx


    Code ( (Unknown Language)):
    1. #include <Password.h>
    2.  
    3.  
    4. boolean started=false;
    5. Password password = Password( "1234" );
    6.  
    7. byte currentLength = 0;
    8.  
    9.  
    10. void setup(){
    11.   Serial.begin(9600);
    12.   Serial.println("Enter Password");
    13.  
    14.  
    15. }
    16.  
    17. void loop()
    18. {
    19.  
    20. if(started){
    21.  
    22. char smsbuffer = Serial.read();
    23.          
    24. String n=smsbuffer;  
    25.  
    26. if(gsm.readSMS(smsbuffer, 5, n ,5) == 0){
    27. {  
    28. switch (smsbuffer){
    29.   case 'Reset': //reset password
    30.   password.reset();
    31.   currentLength = 0;
    32.    Serial.println("\tPassword is reset!");
    33.    
    34.    break;
    35.       case '1234': //evaluate password
    36.         if (password.evaluate()){
    37.           Serial.println("\tAuthorized!");
    38.           mainp();
    39.         }else{
    40.           Serial.println("\tUnauthorized");
    41.         }
    42.    break;
    43. default: //append any keypress that is not a '!' nor a '1234'
    44.         password.append(smsbuffer);
    45.         currentLength++;
    46.        
    47.         //Print some feedback.
    48.         Serial.print("Enter password: ");
    49.         for (byte i=0; i<currentLength; i++){
    50.           Serial.print('*');
    51.         }
    52.         Serial.println();
    53.      }
    54.   }
    55. }
    56. }
    57.  
    58.  
    59.  
    60. void mainp()
    61.  
    62. {
    63. }
    64. }
     
    Last edited: Aug 15, 2013
  2. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    .....and what is "the device"?

    My telepathy device is on the fritz...
     
  3. brian25

    Thread Starter Member

    May 13, 2013
    37
    0
    i'm using arduino.

    can you help me with codings? i'm working now with arduino library password.h
    the concept is when the pass is correct it will jump to the main program and it also have change or reset pass

    just don't mind the eeprom. tnx
     
    Last edited: Aug 15, 2013
  4. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    If you are using an Arduino, I'm sure there's a library to do that. Check the Arduino website...
     
Loading...