Go Down

Topic: Writing password to flash memory on Due (Read 424 times) previous topic - next topic

Benoson

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 :)

septillion

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.
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

Benoson

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.

septillion

Then open up the example and tell us which part you don't understand :)
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

Benoson

Code: [Select]
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?

septillion

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

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)

where is the writing to flash part
Code: [Select]
dueFlashStorage.write(0,b1);

and where do i read it from?
Code: [Select]
Serial.print(dueFlashStorage.read(0));


Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

Benoson


septillion

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.
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

Go Up