131Views4Replies

Author Options:

Help developing rfid scanner program for arduino? Answered


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)
http://www.multiupload.com/XZQWCQ7UW0

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

4 Replies

user
mjcarr01 (author)2011-01-04

You are not reinitializing your vars after a read

Select as Best AnswerUndo Best Answer

user
newrev426 (author)mjcarr012011-01-06

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?

Select as Best AnswerUndo Best Answer

user
mjcarr01 (author)newrev4262011-01-07

void loop()
 {
     time = millis();
     Serial.println(time);
     unsigned long currentMillis = millis();
     code[0] = '\0';

Since "code" never gets reinitialized after a read, it will still hold the last card value read.

Select as Best AnswerUndo Best Answer

user
newrev426 (author)mjcarr012011-01-07

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.

Select as Best AnswerUndo Best Answer