Back to Parent

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

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

//#include "MFRC522.h" //obtained from source mentioned above
 
#define SS_PIN SS
#define RST_PIN D2

Servo myservo;

int led = D5;
 
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");
	pinMode(led,OUTPUT);
	digitalWrite(led,HIGH);
	
	myservo.attach(D6);   // attach the servo on the D6 pin to the servo object
}
 
void loop() {
	// Look for new cards
	digitalWrite(led,LOW);
	delay(3000);
	if ( ! mfrc522.PICC_IsNewCardPresent()) {
		Serial.println("card not detected");
		return;
	}
	Serial.println("New card Detected");
	digitalWrite(led,HIGH);
	myservo.write(90);
    delay(1000);
    myservo.write(0);
    delay(1000);
	digitalWrite(led,LOW);
	
	//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