Skip to content

Instantly share code, notes, and snippets.

@Xplorer001
Created June 18, 2016 14:42
Show Gist options
  • Save Xplorer001/79cd443937099bb4338d03ae14e21aa9 to your computer and use it in GitHub Desktop.
Save Xplorer001/79cd443937099bb4338d03ae14e21aa9 to your computer and use it in GitHub Desktop.
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 5 // Configurable, see typical pin layout above
#define SS_PIN 13 // Configurable, see typical pin layout above
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
void setup() {
// delay(5000);
Serial.begin(9600); // Initialize serial communications with the PC
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
Serial.println("in setup");
SPI.begin(); // Init SPI bus
Serial.print("spi intialized");
mfrc522.PCD_Init(); // Init MFRC522
Serial.print("card intialized intialized");
mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details
Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
}
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));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment