Need Help with Database /EEprom(RFID)

hello everyone !,
I am fairly new to Arduino , but i am very keen in learning more about Arduino,At the moment I am trying to build a project using Parallax RFID reader and servo where there are four users( RF ID cards) and the servo acts as a gate , I was interested in making a Table or sort of a database to keep the record of the 4 users . I have already managed to write the code for the reader and the servo to work but I was just wondering if it was possible to create a table and make changes in the table which would automatically make changes in the code. When i say changes, i mean giving access or denying access.

I do apologise, if my statements don’t make any sense , please be gentle with me :slight_smile:
I would be extrememly grateful If anyone could give me heads up and hints to get started.

Much appreciated
Thanks

which would automatically make changes in the code.

No.

When i say changes, i mean giving access or denying access.

Yes.

You have to define what you want to do. In these sorts of system there is normally an enroll mode. This can store a token in EEPROM either to replace an existing entry or create a new one. For access you need to search this table to see if the card you have is in the table.

This is the sort of thing I do in this project:-

RFID Sequencer

The code is on the site and you need small sections of it, hope you can find what you are looking for.

Really Appreciate ur reply.

I do understand quite a bit of what you said , And your project was a very good reference as well .However It would be nice if you could direct me to something of a much smaller scale or a link to an example maybe ?

I also wanted to know if it was possible to do this using arrays but I haven't got any clue on to how to write a file using arrays and I have referred to couple of books but Didnt find a proper solution , hope you can direct me to some where.

Many thanks

Saving the token in memory is done by this:-

void saveToken(int point){ // saves the token in EEprom memory at point
    EEPROM.write(point, (tokensOnBoard[0] >> 24) & 0xff);
    EEPROM.write(point+1, (tokensOnBoard[0] >> 16) & 0xff);
    EEPROM.write(point+2, (tokensOnBoard[0] >> 8) & 0xff);
    EEPROM.write(point+3, tokensOnBoard[0] & 0xff);

This takes the 4 byte long int tokensOnBoard[0] and splits it up into 4 bytes and stores it in EEPROM at an address passed into it called point.
This:-

int matchToken(unsigned long token){
   int i = 0;
   boolean found = false;
   while( found == false && i < 1000){
     if( EEPROM.read(i) == ((token >> 24)& 0xff) &&  EEPROM.read(i+1) == ((token >> 16)& 0xff)
             &&  EEPROM.read(i+2) == ((token >> 8)& 0xff) &&  EEPROM.read(i+3) == (token & 0xff) ){
               found = true;
           }
           if(!found) i +=4; // move on to the start of the next entry
   }
   if(found) return i; else return -1;
 }

searches the EEPROM memory for a match of a token passed into it.

This:-

int findFreeEntry(){
   int i = 0;
   boolean found = false;
   while( found == false && i < 1000){
     if( EEPROM.read(i) == 0xff && EEPROM.read(i+1) == 0xff && EEPROM.read(i+2) == 0xff && EEPROM.read(i+3) == 0xff ) found = true;
     if(!found) i +=4;
    }
      if(found) return i; else return -1;
 }

searches the EEPROM memory for a free entry. It returns the address of the next free entry in the data base or -1 if the memory is full.