#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
void setup() {
Serial.begin(9600); // Initialize serial communications with the PC
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522 card
Serial.println("Scan PICC to see UID and type...");
}
void loop() {
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
// Dump debug info about the card. PICC_HaltA() is automatically called.
mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}
Here is the updated code just to find UID of my card
the actual problem is it doesn't give the uid of my card and my code doesn't work
Is it the code problem or the component problem
no I cant see that
but that was what it was supposed to look like
Does that give the correct information?
no it doesn't give any info
that's what made me think if the code is wrong or the components are bricked
No it is not you don't just throw in a
Have you looked at the specific example for the DumpInfo example? You don't just throw in that line.
Build on the examples that come with the MFRC522 library.
So first try the Dump info and then try the Access control example.
Your original sketch worked just fine for me with an Uno R3 and the circuit shown in the schematic below:
Serial output, first with the card with the matching UID, then a different one:
Connecting to /dev/ttyUSB0. Press CTRL-C to exit.
Tap RFID/NFC Tag on reader
Authorized Tag
Rotate Servo Motor to 90°
Unauthorized Tag with UID: 30 2C B2 56
As noted by @van_der_decken are your arduino and rfid boards using the same supply voltage ( which also means the both support that voltage ) ?
If not are you using a level translator to interface the two?
ok guys the problem is solved i have consulted with an expert person he told me that you need to solder the pins of rfid reader
that was the actual problem
ya the problem was with no solder in rfid reader