I Have Made Sure The Reader Works Using The Examples But I Have No Clue How To Write A Keyfobs Info Or How To Read It.
All I Want To Do Is Have An Arduino Read A Code From The RFID Card And Then Send A Serial Message Just Involving The Code From It
the examples only dump all the data available on the chip using one debug command which is no good or it reads data from the chip and then writes data, it doesn't tell me what its writing or how its writing it, it just does it, again, not that helpful anyone got any experience with this library?
the examples only dump all the data available on the chip using one debug command which is no good
What is no good? The code example or the data?
or it reads data from the chip and then writes data, it doesn't tell me what its writing or how its writing it
What it's writing, and how, is hard-coded. Open your eyes; read the code. If you don't understand it, that's fine. But, you need to post the code if you want help understanding it.
i managed to work out what functions control the reading of the UID from the cards and key fobs and have now got that working, thanks for all the help guys!!!!
I've included the code below for anyone who needs it, all it does is read the UID then print it to the serial port in a HEX format
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
byte cardPresent;
void setup() {
Serial.begin(9600); // Initialize serial communications with the PC
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522 card
// Serial.println("Ready!");
}
void loop() {
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
//Serial.print("Card UID:");
for (byte i = 0; i < mfrc522.uid.size; i++) {
//Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
}
Serial.println();
delay(5000);
}
return inside the loop() function always looks odd to me. Even though it works it is not obvious where it is returning to as the code that calls loop() repeatedly is hidden from view.
My preferred way would be something like this.
void loop()
{
// Look for new cards
if (mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial())
{
//Serial.print("Card UID:");
for (byte i = 0; i < mfrc522.uid.size; i++) {
//Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
}
Serial.println();
delay(5000);
}
}
which I personally find easier to read and understand, but each to their own.