Writing password to flash memory on Due

Hello, i have an assignment to hand in 3 days in Arduino, and part of it is to write a password to Arduino Due flash memory and to be able to change it trough keypad (which i have), and even when the arduino is unplugged from power and re-plugged the password will be saved.
(being able to change it and to save the change is an important part).

i saw this library called "Due flash storage" but i have no idea how to use it and the examples there are kinda not understandable for me.
if anyone could help me i would really appreciate it :slight_smile:

Wow, if you don't understand those examples you're indeed in for a hard time...

But just whining about it doesn't get you anywhere. Chop it up into pieces (for example reading the keypad, handling it as a password and writing/reading it from flash) and start writing code. Don't expect to write the full program, take baby steps and write tests to see if you understand the code.

the keypad part is alright, i can handle it, and yes i am new to code and the only part i dont understand is the writing\ reading from the flash. and that's where i need help.

Then open up the example and tell us which part you don't understand :slight_smile:

void setup() {
  Serial.begin(115200);
  byte b1 = 3;
  uint8_t b2 = 1;
  dueFlashStorage.write(0,b1);
  dueFlashStorage.write(1,b2);
  //dueFlashStorage.write(2,b2);
}

void loop() {
  // read from flash at address 0 and 1 and print them
  Serial.print("0:");
  Serial.print(dueFlashStorage.read(0));
  Serial.print(" 1:");
  Serial.print(dueFlashStorage.read(1));  
  
  // read from address 2, increment it, print and then write incremented value back to flash storage
  uint8_t i = dueFlashStorage.read(2)+1;
  Serial.print(" 2:");
  Serial.print(dueFlashStorage.read(2)); 
  dueFlashStorage.write(2,i);
  
  Serial.println();
  delay(1000);
}

See, Now i want to make a password 4 ints long, and i don't know where is the writing to flash part, and where do i read it from?

I said open it up, don't just post it here...

Benoson:
See, Now i want to make a password 4 ints long,

Why do you want to make it 4 int's long? Do you have a keyboard with 65535 keys? Or do you mean 4 numbers between 0 and 9 (inclusive)? That you can just store in a byte or leave it as a char (which is also a byte)

Benoson:
where is the writing to flash part

dueFlashStorage.write(0,b1);

Benoson:
and where do i read it from?

Serial.print(dueFlashStorage.read(0));

What does "(0,b1)" mean?

Address location 0
b1 is the variable but that should have been obvious.

Like the documentation says, it's almost like EEPROM on a Uno.

Writing password to flash memory on Due- some problem please help see below form

https://forum.arduino.cc/index.php?topic=556775.msg3797002#msg3797002