hello All,
i want to save multidimensional array (decimal value) into EEprom. it is working for integer but sometime i need to save decimal value too.
can somebody help me in this regards??
thanks in advance.
#include <EEPROM.h> #include <SPI.h>
const int rows = 2;
const int columns = 3;
int array1[ rows ][ columns ] = { { 55.5, 2, 3 }, { 4, 5, 6 } };
int addr;
void setup () {
Serial.begin(9600);
}
void loop () {
Serial.println ("Values in array1 by row are: ") ;
An obvious solution to this is to realize that a float value in Arduino is basically just a memory area of 4 bytes, which you can store one by one in EEPROM. When retrieving them, you do the opposite.
So effectively you would have a routine that reads each individual byte from the float value (regardless of what the value of the float looks like), and a routine that reads them back from EEPROM for retrieval.
Where do you think that "55.5" floating point number is going ?
Spoiler: Into thin air. Only the whole number of "55" is to heavy to fly away and that get stored in the integer.
I am sorry, i am beginner in programming and trying hard to learn it.
It is just an example. I am going to use array to store 3 different sensor values and every column is specify for one sensor value.
could you please help me to figure it out how can i update Row values for Sensor 1.
i am comparing the two output of sensor on a different time (t1= 34m3, t2= 55.3m3) and if t1 is greater or equals to t2, t1 value shall go to a[R1][C1] and t2 value shall store to a[R2][C1].
You have three sensors and assume that these are S1, S2, and S3. What types of sensors are they? Does each sensor produce one output? What is the range of the output of S1 in floating point format (For example)?
Note that:
In Arduino UNO, NANO, MEGA and DUE, float allocates 4-bte memory space to hold floating point number of binary32 standard.
In Arduino DUE, double allocates 8-bte memory space to hold floating point number of binary64 standard.