Back to Parent

// This #include statement was automatically added by the Particle IDE.
#include "MFRC522.h"


//obtained from source mentioned above
 
#define SS_PIN SS
#define RST_PIN D2
 
MFRC522 mfrc522(SS_PIN, RST_PIN);	// Create MFRC522 instance.
 
void setup() {
	// Initialize serial communications with the computer
	Serial.begin(9600);	
	mfrc522.setSPIConfig(); // sets up SPI config
 
	mfrc522.PCD_Init();	// Initialize RC522 card
	Serial.println("Start Scanning");
}
 
void loop() {
	// Look for new cards
	if ( ! mfrc522.PICC_IsNewCardPresent()) {
		return;
	}
	//Serial.println("New card Detected");
	// Read tapped card data
	if ( ! mfrc522.PICC_ReadCardSerial()) {
		return;
	}
 
	//Dump all card data to Serial
  //Uncomment this if you want to debug / find info on tags
	//mfrc522.PICC_DumpToSerial(&(mfrc522.uid));

  // get the ID 
 String id;
  for (byte i = 0; i < mfrc522.uid.size; i++) {
		// Create a RFID Hexdecimal String
		id += String(mfrc522.uid.uidByte[i], HEX);

	}
	// Convert to Uppercase
	id.toUpperCase();

  // print it to the console.
	Serial.print(id);
	Serial.println();


	// If it is this card, do something
	if (id == "44681A4A6E81" || "45981A4A6E81" ) {
		Particle.publish("AlexaNo", id, PRIVATE);
	}
    
	// Reset Id
	id = "";
	
	if (id == "44781A4A6E81" || "46E81A4A6E81" || "45A81A4A6E81" ); {
            Particle.publish("AlexaYes", id, PRIVATE);
    }
    
    	// Reset Id
	id = "";
	mfrc522.PICC_HaltA();
	mfrc522.PCD_StopCrypto1();
}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0