EEPROM Storage

Hello…

The code is attached below:

In the following code (which my friend mailed to me), right in the beginning of Setup() routine, a for loop is used to copy data from EEPROM. Please guide me how it works. How EEPROM already knows that gyro_address in stored in eeprom_data[32] location as I didn’t stored its address at that location…

I’m in really need of this help. A little help will be appreciated. Thanks in advance…

YMFC-AL_Flight_controller.ino (40.4 KB)

(deleted)

code file is attached. kindly check it

(deleted)

why dear…what happened?

OK, to bring you up to speed.
Forum etiquette is in place for several reasons - none of which you are aware - because you didn’t read the ‘posting’ guidelines.

Modifying previous posts is a no-no, because you disrupt the chain of reading and developing a solution… and you can make subsequent posts look silly because you have changed the reason for replying.

Posting your code in-line with tags is preferable, but if the code is too large, attach it as you did - but - as a text file (ino is text, but can’t be opened by many people that are trying to help you).

for(start = 0; start <= 35; start++)eeprom_data[start] = EEPROM.read(start);

Reads EEPROM addresses 0–35 into an array called eeprom_data, which isn’t really all that helpful, because EEPROM reads are pretty fast anyway.

The code is comprehensive, but I can see a few places where it is unnecessarily wordy or slower than needs to be, but that’s not your question.

To answer that - there is NOWHERE in that code which WRITES to the EEPROM, so I’m guessing the original author has a separate program he used to calibrate the system - which writes the ‘constants’ to the EEPROM before this code is loaded and run. Which in turn may be a huge waste of effort, as the constants are constant - so why use EEPROM, when they could be stored in PROGMEM with a little thought & effort ?

thanks for replying. You were right about your opinion. The author of the code has written another code file for storing info to EEPROM.

Thanks. Stay blessed