0% found this document useful (0 votes)
14 views2 pages

Project - WC Using Rfid

Uploaded by

mohitnavalger17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Project - WC Using Rfid

Uploaded by

mohitnavalger17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#include <SPI.

h>
#include <MFRC522.h>
#include <Servo.h>

#define SS_PIN 10
#define RST_PIN 9
#define SERVO_PIN A5

MFRC522 rfid(SS_PIN, RST_PIN);


Servo servo;

byte authorizedUID[4] = {0x39, 0x2B, 0xD6, 0xB0};


int angle = 0; // the current angle of servo motor

void setup() {
[Link](9600);
[Link](); // init SPI bus
rfid.PCD_Init(); // init MFRC522
[Link](SERVO_PIN);
[Link](angle); // rotate servo motor to 0°

[Link]("Tap RFID/NFC Tag on reader");


}

void loop() {
if (rfid.PICC_IsNewCardPresent()) { // new tag is available
if (rfid.PICC_ReadCardSerial()) { // NUID has been readed
MFRC522::PICC_Type piccType = rfid.PICC_GetType([Link]);

if ([Link][0] == authorizedUID[0] &&


[Link][1] == authorizedUID[1] &&
[Link][2] == authorizedUID[2] &&
[Link][3] == authorizedUID[3] ) {
[Link]("Authorized Tag");

// change angle of servo motor


if (angle == 0)
angle = 90;
else //if(angle == 90)
angle = 0;

// control servo motor arccoding to the angle


[Link](angle);
[Link]("Rotate Servo Motor to ");
[Link](angle);
[Link]("°");
} else {
[Link]("Unauthorized Tag with UID:");
for (int i = 0; i < [Link]; i++) {
[Link]([Link][i] < 0x10 ? " 0" : " ");
[Link]([Link][i], HEX);
}
[Link]();
}

rfid.PICC_HaltA(); // halt PICC


rfid.PCD_StopCrypto1(); // stop encryption on PCD
}
}
}

You might also like