6: Question about RFID-522 Reader
I wanted to do the "unlock the door using an RFID chip" trick. So I got a device from Sainsmart.
http://www.sainsmart.com/arduino/arduino-components/sainsmart-mifare-rc522-card-read-antenna-rf-rfid-reader-ic-card-proximity-module.html
Besides the sensor the package handily included one-each RFID keyfob- and credit card-type test devices. I downloaded a library and sample sketch from the Internet, wired up the device and -- it didn't work. I downloaded a different library and sketch -- also didn't work. I was trying to test using the keyfob. Then I accidentally tested using the card. Worked! It had always worked.
I complained to Sainsmart and they eventually sent me a whole 2nd setup (new device, new fob, new card). Both cards work, neither of the fobs are recognized.
Anyone understand this problem?
Here's my sketch:
/* Nano pins:
RST: Pin 9
SS: Pin 10
MOSI: Pin 11
MISO: Pin 12
SCK: Pin 13
*/
#include <SPI.h>
#include <RFID.h>
#define SS_PIN 10
#define RST_PIN 9
RFID rfid(SS_PIN,RST_PIN);
int serNum[5];
void setup(){
Serial.begin(9600);
SPI.begin();
rfid.init();
}
void loop(){
int i;
if(rfid.isCard()) {
if(rfid.readCardSerial()) {
for(i = 0; i <= 4; ++i) {
Serial.print(rfid.serNum[i]); Serial.print(" ");
}
Serial.println("");
} else {
Serial.println("nr");
}
} else {
Serial.println("-");
}
rfid.halt();
delay(1000);
}
No comments:
Post a Comment