Beruflich Dokumente
Kultur Dokumente
h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// declaration of Tag ID
char tagB[]="FF000B6AF16F";
// declaration of Tag ID
char tagC[]="13004A1B8AC8";
// declaration of Tag ID
char tagD[]="FF000C0BD62E";
// declaration of Tag ID
char tagE[]="13004A889445";
int o=1;
int n=0; //for Tag A to check the correct password
int m=0;
int v=0; //for Tag B to check the correct password
int x=0; //for Tag C to check the correct password
char input[12];
int count = 0;
input[] character array
boolean flag = 0;
boolean flagB=0;
boolean flagC=0;
{
'4','5','6' }
,
{
'7','8','9' }
,
{
'*','0','#' }
};
byte rowPins[ROWS] = {17, 16, 15, 14}; //connect to the row pinouts of the kp
byte colPins[COLS] = {10, 9, 8}; //connect to the column pinouts of the kp
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
pinMode(13,OUTPUT);
pinMode(7,OUTPUT);
Serial.begin(9600);
Monitor
//screenwidth=16
screenheight=2
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Employee");
lcd.setCursor(0,1);
lcd.print("ManagementSystem");
delay(4000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Please move");
lcd.setCursor(0,1);
lcd.print(" your tag below");
delay(1000);
}
void loop()
{
if(Serial.available())// Check if there is incoming data in the RFID Reader Serial
Buffer.
{
count = 0; // Reset the counter to zero
/* Keep reading Byte by Byte from the Buffer till the RFID Reader
Buffer is empty
or till 12 Bytes (the ID size of our Tag) is read */
while(Serial.available() && count < 12)
{
input[count] = Serial.read(); // Read 1 Byte of data and store
it in the input[] variable
count++; // increment counter
delay(10);
}
/* When the counter reaches 12 (the size of the ID) we stop and
compare each value
}
else
{ Serial.println("else");
flag= 0;
}
/* if the ID values don't match, set flag variable to 0 and
stop comparing by exiting the while loop */
if(input[count]==tagB[count])
{
flagB = 1; // everytime the values match, we set the flag
variable to 2
}
else
{
flagB= 0;
}
/* if the ID values don't match, set flag variable to 0 and
stop comparing by exiting the while loop */
if(input[count]==tagC[count])
{
flagC = 1; // everytime the values match, we set the flag
variable to 2
}
else
{
flagC= 0;
}
/* if the ID values don't match, set flag variable to 0 and
stop comparing by exiting the while loop */
count++; // increment count
}//while
}
if(flag == 1) // If flag variable is 1, then it means the tags match
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Enter PIN:");
lcd.setCursor(0,1);
n=readKeypad(PA);
if(n==1)
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Welcome Ankit");
delay (1000);
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage
level)
delay(3000);
digitalWrite(13, LOW); // turn the LED off (LOW is the voltage
level)
delay(3000);
goto abhay;
}
else
{
lcd.clear();
lcd.print("Entry denied");
}
}
else
{
if(flagB ==1)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Enter PIN:");
lcd.setCursor(0,1);
v=readKeypad(PB);
if(v==1)
{
lcd.print("Access Allowed");
lcd.setCursor(0,1);
lcd.print("Welcome Parth Tyagi ");
delay (2000);
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage
level)
delay(3000);
digitalWrite(13, LOW); // turn the LED off (LOW is the voltage
level)
delay(3000);
goto abhay;
}
}
else
{
if(flagC==1)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Enter PIN:");
lcd.setCursor(0,1);
x=readKeypad(PC);
if(x==1)
{
lcd.print("Access Allowed");
lcd.setCursor(0,1);
lcd.print("Welcome Abhay");
delay(1000);
digitalWrite(13, HIGH); // turn the LED on (HIGH is the
voltage level)
delay(3000);
digitalWrite(13, LOW); // turn the LED off (LOW is the voltage
level)
delay(3000);
goto abhay;
}
}
else
{
lcd.clear();
lcd.print("Access Denied");// Incorrect Tag Message
lcd.setCursor(0,1);
lcd.print("Tag is invalid");
delay(1000);
digitalWrite(7, HIGH); // turn the LED on (HIGH is the voltage
level)
delay(4000);
digitalWrite(7, LOW); // turn the LED on (HIGH is the voltage
level)
}
}
/* Fill the input variable array with a fixed value 'L' to overwrite
all values getting it empty for the next read cycle */
for(count=0; count<12; count++)
{
input[count]= 'L';
}
count = 0; // Reset counter variable
}
}
abhay:
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Please move");
lcd.setCursor(0,1);
lcd.print(" your tag below");
delay(1000);
}
int checkPIN(char at[])
{
int correct=0;
int i;
if (attempt[i]==at[i])
{
correct++;
}
}
int p=0;
if (correct==6)
{
p=1;
lcd.print("* Correct PIN *");
delay(1000);
lcd.clear();
}
else
{
lcd.print(" * Try again *");
delay(1000);
lcd.clear();
lcd.print(" Enter PIN...");
}
if (key)
{
lcd.print("#");
delay(200);
attempt[z]=key;
z++;
switch(key)
{
case '*':
z=0;
allclear();
break;
case '#':
z=0;
delay(200); // for extra debounce
lcd.clear();
n=checkPIN(ar);
Serial.println("n is");
Serial.println(n);
break;
}
}
p++;
}//outermost while
return (n);
}
void allclear()
{
for(int q=0;q<6;q++)
{
attempt[q]='0';
}
}