Hello crazy arduino fans...
As the title says, I am looking a way to find the min and max values of 500 data the has been stored into the internal EEPROM of arduino.
Please advice
Regards
Oldnick
Hello crazy arduino fans...
As the title says, I am looking a way to find the min and max values of 500 data the has been stored into the internal EEPROM of arduino.
Please advice
Regards
Oldnick
Read the first value. Store it as both min and max value. Read each of the other values. If the value read is less than min, reset min. If the value read is greater than max, reset max.
min=MAX_VAR; //reset minimum to the max
max=MIN_VAR; //reset the max to the minimum
for (index = 0; index < 500; index++) {
var = read_eeprom(index); //read from the eeprom
min=(var < min)?var:min; //revise min if min<var
max=(var>max)?var:max; //revise max
}
Just tailor to your applications
Thanks dhenry.Your code with some changes was OK.
BUT how I can store and after read in internal EEPROM float numbers (negative and possitive).
That is my code for write
#include <EEPROM.h>
#include "EEPROMAnything.h"
void setup(){
}
void loop()
{
//for (int i=0; i < noElem-1; i++){
EEPROM_writeAnything(0, -12.5);
delay(500);
EEPROM_writeAnything(1, -10.00);
delay(500);
EEPROM_writeAnything(2, -5.7);
delay(500);
EEPROM_writeAnything(3, 0);
delay(500);
EEPROM_writeAnything(4, 2.90);
delay(500);
EEPROM_writeAnything(5, 4);
delay(500);
EEPROM_writeAnything(6, 5.5);
delay(500);
}
and that is the code for reading the data
#include <EEPROM.h>
#include "EEPROMAnything.h"
int address = 0;
float value;
void setup()
{
// initialize serial and wait for port to open:
Serial.begin(9600);
}
void loop()
{
// read a byte from the current address of the EEPROM
EEPROM_readAnything(address,value);
Serial.print(address);
Serial.print("\t");
Serial.print(value);
Serial.println();
address = address + 1;
if (address == 512)
address = 0;
delay(500);
}
I can read correct the data
Pease advice
Oldnick
EEPROM_writeAnything(0, -12.5);
delay(500);
EEPROM_writeAnything(1, -10.00);
delay(500);
EEPROM_writeAnything(2, -5.7);
delay(500);
EEPROM_writeAnything(3, 0);
delay(500);
EEPROM_writeAnything(4, 2.90);
delay(500);
EEPROM_writeAnything(5, 4);
delay(500);
EEPROM_writeAnything(6, 5.5);
How are you fitting 4 bytes per byte of EEPROM?
The EEPROM_writeAnything method returns a value that might be important to you. It is the next address you can write to.
EEPROM_readAnything(address,value);
Serial.print(address);
Serial.print("\t");
Serial.print(value);
Serial.println();
address = address + 1;
You can't read a float from one byte.
I can read correct the data
I'm going to guess that a period is not the only thing missing from this sentence. "not" belongs in there some where.