Arduino Programs
Arduino Programs
*
----------------------------------------------------------------------------------------------------
----------------
*
----------------------------------------------------------------------------------------------------
----------------
* This is a MFRC522 library example; for further details and other examples see:
https://github.com/miguelbalboa/rfid
* Example sketch/program showing how to read data from a PICC (that is: a RFID
Tag or Card) using a MFRC522 based RFID
* When the Arduino and the MFRC522 module are connected (see the pin layout
below), load this sketch into Arduino IDE
* then verify/compile and upload it. To see the output: use Tools, Serial Monitor
of the IDE (hit Ctrl+Shft+M). When
* you present a PICC (that is: a RFID Tag or Card) at reading distance of the
MFRC522 Reader/PCD, the serial output
* will show the ID/UID, type and any data blocks it can read. Note: you may see
"Timeout in communication" messages
* If your reader supports it, this sketch/program will read all the PICCs presented
(that is: multiple tag reading).
* So if you stack two or more PICCs on top of each other and present them to the
reader, it will first output all
* details of the first and then the next PICC. Note that this may take some time as
all data blocks are dumped, so
* -----------------------------------------------------------------------------------------
* -----------------------------------------------------------------------------------------
*/
#include <SPI.h>
#include <MFRC522.h>
void setup() {
void loop() {
// Reset the loop if no new card present on the sensor/reader. This saves the
entire process when idle.
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}
Access control
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 02
#define RST_PIN 05
byte readCard[4];
// Create instances
/
******************************************************************
****************************
* setup() function
******************************************************************
****************************/
void setup()
Serial.begin(9600);
SPI.begin();
mfrc522.PCD_Init();
delay(4);
mfrc522.PCD_DumpVersionToSerial();
Serial.println("--------------------------");
* loop() function
void loop()
//----------------------------------------------------------------------
while (getID()) {
if (tagID == MasterTag){
Serial.println("--------------------------");
else{
Serial.println("--------------------------");
delay(2000);
//----------------------------------------------------------------------