0% found this document useful (0 votes)
19 views3 pages

Include

This document contains an Arduino sketch for an RFID reader using the MFRC522 library. It initializes the RFID reader, waits for a badge to be presented, and checks if the UID of the presented badge matches a stored UID, indicating whether the badge is valid or invalid. The program provides visual feedback through LEDs and prints messages to the serial monitor based on the validity of the badge presented.

Uploaded by

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

Include

This document contains an Arduino sketch for an RFID reader using the MFRC522 library. It initializes the RFID reader, waits for a badge to be presented, and checks if the UID of the presented badge matches a stored UID, indicating whether the badge is valid or invalid. The program provides visual feedback through LEDs and prints messages to the serial monitor based on the validity of the badge presented.

Uploaded by

Joseph YLANDJO
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include <SPI.

h>

#include <MFRC522.h>

const int comm=10;

const int RST =9;

const int MS=11;

const int M=12;

const int CK=13;

const int red_led=6;

const int green_led=5;

String uid;

String UIDbadge;

MFRC522 rfid (comm,RST);

void setup() {

Serial.begin(9600);

SPI.begin();

pinMode(SS,OUTPUT);

pinMode(RST,OUTPUT);

digitalWrite(RST,HIGH);

digitalWrite(SS,HIGH);

Serial.println("lecteur RFID prét. Présentez votre badge ");

while(uid==""){

if (rfid.PICC_IsNewCardPresent()){

if (rfid.PICC_ReadCardSerial()){
for(byte i=0;i<rfid.uid.uidByte[i];i++){

uid+= String(rfid.uid.uidByte[i],HEX);

uid.toUpperCase();

rfid.PICC_HaltA();

UIDbadge=uid;

Serial.println("votre UID est enregistré ");

void loop() {

Serial.println("Presenter votre badge ");

if (rfid.PICC_IsNewCardPresent()){

if (rfid.PICC_ReadCardSerial()){

uid="";

for(byte i=0;i<rfid.uid.uidByte[i];i++){

uid+= String(rfid.uid.uidByte[i],HEX);

uid.toUpperCase();

rfid.PICC_HaltA();

}
if (UIDbadge==uid){

digitalWrite(green_led,HIGH );

delay(2000);

digitalWrite(green_led,LOW);

Serial.println(" Badge valide");

else{

digitalWrite(red_led,HIGH);

delay(2000);

digitalWrite(red_led,LOW);

Serial.println(" Badge invalide");

You might also like