Hi
I have a problem with the EDB library.
I’m trying to save some information , reset the system and then read it from memory. But every time I’m trying to read it I get zeroes in the read data!
In the “Save Mode” I activate the sketch below, save the data, read it in the same cycle, that’s step works ok.
But after restart when I activate only the “Read Mode” I get only zeroes.
Can’t understand what I’m doing wrong.
I’m using the arduino MEGA
Thanks
R.G
MYSKETCH
#include <Wire.h>
#include <L3G.h> //Gyro
#include "Arduino.h"
#include <EDB.h> //MEMORY
#include <LSM303.h> //Magnometer
// --------------Use the Internal Arduino EEPROM as storage-----------
#include <EEPROM.h>
#define TABLE_SIZE 4096
#define RECORDS_TO_CREATE 5
struct CallibratedValue
{
int motor_speed_A ;
int motor_speed_B ;
}
CallibratedValue;
// The read and write handlers for using the EEPROM Library
void writer(unsigned long address, byte data)
{
EEPROM.write(address, data);
}
byte reader(unsigned long address)
{
return EEPROM.read(address);
}
// Create an EDB object with the appropriate write and read handlers
EDB db(&writer, &reader);
void setup()
{
Creating Recrods
Serial.println("Creating Records...");
int recno;
for (recno = 1; recno <= RECORDS_TO_CREATE; recno++)
{
CallibratedValue.motor_speed_A = recno;
CallibratedValue.motor_speed_B = recno * 2;
db.appendRec(EDB_REC CallibratedValue);
}
Reading Records
Serial.print("Record Count: "); Serial.println(db.count());
for (int recno = 1; recno < RECORDS_TO_CREATE; recno++)
{
db.readRec(recno, EDB_REC CallibratedValue );
Serial.print("ID: "); Serial.println(CallibratedValue.motor_speed_A);
Serial.print("Temp: "); Serial.println(CallibratedValue.motor_speed_B);
}
}