Help developing rfid scanner program for arduino?

I am developing a rfid scanner that will be embedded in a seat and will turn on things etc. I wrote the code to do it but for some reason when I swipe the tag over the parallax reader it does the designated task up to 4 times when it is required to only do it once per swipe. Please help me revise my code so it will only happen once per swipe.

I am using:
parallax reader running at 2400 baud
Arduino Duemilanove
3 LEDs

link to .pde file (change to .txt to read code in wordpad)

-Thanks! I would not ask for help but I have been looking for over a week and I am stuck!?

mjcarr016 years ago
You are not reinitializing your vars after a read
newrev426 (author)  mjcarr016 years ago
Thanks for the help I really appreciate it! I believe I reinitialized the variables but it still does not work. Can you give me specific examples to make sure I am doing it properly?
void loop()
     time = millis();
     unsigned long currentMillis = millis();
     code[0] = '\0';

Since "code" never gets reinitialized after a read, it will still hold the last card value read.
newrev426 (author)  mjcarr016 years ago
Thanks again I hate to be a bother but I tried that bit of code and it still does the same thing. I also tried reinitializing the bytesread and val ints. It seems like it should work but it doesnt. Any more ideas? Thanks in advance.