Getting The RFID Reader Started
created: 19 Feb 2013 08:40
tags:
We attached the Parallax RFID reader to our Arduino UNO and were able to get it to read and print out the name of the ID Tag on the Serial Print monitor.
A late addition to our apparatus came in the form of a fun little buzzer that beeps each time an RFID tag is read.
Code was modified from "Getting Started With RFID" by Tom Igoe:
//RFID With Parallax Reader #include <SoftwareSerial.h> const int tagLength= 10; const int startByte= 0x0A; //Start of Tag const int endByte= 0x0D; //End of Tag char tagID[tagLength + 1]; //Array To Hold the Tag That's Read const short Buzzer = 3; const int rxpin= 6; //Pin 6 Recieves Data From RFID Reader const int txpin= 7; //Pin 7 does nothing in this sketch SoftwareSerial rfidPort(rxpin, txpin); void setup(){ Serial.begin(9600); rfidPort.begin(2400); pinMode(Buzzer, OUTPUT); } void loop(){ digitalWrite(Buzzer, LOW); if (rfidPort.available() > 0){ if(readTag()){ Serial.println(tagID); digitalWrite(Buzzer, HIGH); delay(100); } } } //Now read the tag, and return it to tagID above to print boolean readTag(){ char thisChar = rfidPort.read(); if (thisChar == startByte){ if (rfidPort.readBytesUntil(endByte, tagID, tagLength)){ return true; } } return false; }
Further tests will be conducted to determine how effective the RFID Reader is reading through different materials.