LCD Rfid
LCD Rfid
LCD Rfid
I YouTube Channel
*
*First scan your cards using this code and the ID will appear on the Serial
monitor
*by this command Serial.println(card_ID) just uncomment it, then set the IDs that
you scanned to any name you want
*that means you don't have to upload another code to scan the card IDs.
*/
#include <SPI.h>
#include <MFRC522.h>
//#include <LiquidCrystal.h>// include the library code:
String Log;
String Name;//user name
long Number;//user number
int n ;//The number of card you want to detect (optional)
int ID=1;
void setup() {
//lcd.begin(16, 2);
Serial.begin(9600); // Initialize serial communications with the PC
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522 card
pinMode(RedLed,OUTPUT);
pinMode(GreenLed,OUTPUT);
pinMode(Buzzer,OUTPUT);
//lcd.setCursor(2,0);
//lcd.print("Good Morning");//Wlecome Message will appear in the beginning.
delay(200);
}
void loop() {
//look for new card
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;//got to start of loop if there is no card present
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;//if read card serial(0) returns 1, the uid struct contians the ID of the
read card.
}
if(card_ID==Name1){
Name="First employee";//user name
Number=123456;//user number
j=0;//incresd by one for every user you add
s=0;//++1
}
else if(card_ID==Name2){
Name="Second employee";//user name
Number=789101;//user number
j=1;//++1
s=1;//++1
}
else if(card_ID==Name3){
Name="Third employee";//user name
Number=789101;//user number
j=2;//++1
s=2;//++1
}
else if(card_ID==Name4){
Name="Fourth employee";//user name
Number=789101;//user number
j=3;//++1
s=3;//++1
}
else if(card_ID==Name5){
Name="Fiveth employee";//user name
Number=789101;//user number
j=4;//++1
s=4;//++1
}
else if(card_ID==Name6){
Name="Sixth employee";//user name
Number=789101;//user number
j=5;//incresd by one for every user you add
s=5;//++1
}
else{
digitalWrite(GreenLed,LOW);
digitalWrite(RedLed,HIGH);
goto cont;//go directly to line 188
}
cont:
delay(1000);
digitalWrite(GreenLed,LOW);
digitalWrite(RedLed,LOW);
card_ID="";
//if you want to close the Excel when all card had detected and save Excel file in
Names Folder. in my case i have just 2 card (optional)
/*if(n==2){
Serial.println("SAVEWORKBOOKAS,Names/WorkNames");
Serial.println("FORCEEXCELQUIT");
}*/
}