Instructables

RFID Reader! MK: II, Card identifiers

Picture of RFID Reader! MK: II, Card identifiers
Hey guys I'm back with a second version of the code for an RFID scanner! This scanner is a great way to use your cards by holding values, balances, securities and many different things for RFID cards!

Entry Robot Challenge age group 13-17
 
Remove these adsRemove these ads by Signing Up

Step 1: Supplies

Picture of Supplies
one RFID made circuit (version one) or you could follow the circuit diagram here. Read the big box which is a note, it is important.

Step 2: The code!!!!!!!

Picture of The code!!!!!!!
This is a very simple code for comparision, it is actually a bit confusing of how to get your card number to be compared.



#include <SoftwareSerial.h>
#include <avr/interrupt.h>

int  val = 0;
char code[10];
int bytesread = 0;

#define rxPin 8
#define txPin 9
// RFID reader SOUT pin connected to Serial RX pin at 2400bps to pin8

void setup()
{
  Serial.begin(9600);  // Hardware serial for Monitor 9600bps

  pinMode(2,OUTPUT);       // Set digital pin 2 as OUTPUT to connect it to the RFID /ENABLE pin
  digitalWrite(2, LOW);    // Activate the RFID reader
}


void loop()
{
  SoftwareSerial RFID = SoftwareSerial(rxPin,txPin);
  RFID.begin(2400);

  if((val = RFID.read()) == 10)
  {   // check for header
    bytesread = 0;
    while(bytesread<10)
    {  // read 10 digit code
      val = RFID.read();
      if((val == 10)||(val == 13))
      {  // if header or stop bytes before the 10 digit reading
        break;                       // stop reading
      }
      code[bytesread] = val;         // add the digit          
      bytesread++;                   // ready to read next digit 
    }

    if(bytesread == 10)
    {  // if 10 digit read is complete
      Serial.println("TAG code is: ");   // possibly a good TAG
      Serial.print(code);            // print the TAG code
      validateRFID(code);
    }
    bytesread = 0;
    delay(500);                       // wait for a second
  }
}


void validateRFID(char* i) {
  if( strncmp(i,"12000C9DBF", 10) == 0) {
    // if 10 digit code equals "12000C9DBF"
    digitalWrite(13, HIGH); 
    Serial.println(" Correct Tag");
delay(1000);
    digitalWrite(13, LOW);
  } else {
    digitalWrite(13, LOW);
  }
}

Step 3: Enjoy.

Thanks for the comments and PMs, they helped me decide what to include in version 2. Thanks so much, feel free to post comments, have questions, or share your experience. Thanks, Simon
nuruluyul3 months ago

hello.. i need ur help.. iam a newbie in arduino world. and i have to do project for rfid register attendance using arduino. may i know this code are suitable for my project ? i will use existing card exmple student card..i need ur response as soon as possible..tq :)

simonfrfr (author)  nuruluyul3 months ago

Yes this is suitable for your project. What kind of arduino do you own? If you own an Ethernet you can send Card data to a server, and grab time from that server too, to check if the student was tardy, absent, or early.But if you only need one card to work with, then you can use this just to check if the student "scanned" his card. Good luck, if you need any more help feel free to email me @ newtonlabs@bellsouth.net

c1c2c31 year ago
Could you tell me what arduino do you have to use and does the computer have to be connected at the time of the reading
simonfrfr (author)  c1c2c31 year ago
Well, I was using the Arduino Uno, The Arduino reads the RFID READER and you do not really need to have the computer connected for this to work.
c1c2c3 c1c2c31 year ago
And could you also make a video please
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!