Back to Parent

// This #include statement was automatically added by the Particle IDE.
#include <MFRC522.h>
 
#define SS_PIN A2
#define RST_PIN D2
int led1 = D5;
int led2 = D3;
int led3 = D4;
int led4 = D6;

 
MFRC522 mfrc522(SS_PIN, RST_PIN);	// Create MFRC522 instance.
 
void setup() {
    pinMode(led1, OUTPUT);
    pinMode(led2, OUTPUT);
    pinMode(led3, OUTPUT);
    pinMode(led4, OUTPUT);
	// 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()) {
	    digitalWrite(led1, HIGH);
        delay(1500);
        digitalWrite(led2, HIGH);
        delay(1500);
        digitalWrite(led3, HIGH);
        delay(1500);
        digitalWrite(led4, HIGH);
        delay(1500);
	}
	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
	mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}
Click to Expand

Content Rating

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

0