Code:-
//AccessControl.ino
#define Ready 13
#define Relay 12
#define Warning 8
char tag[] ="45003BEC7AE8"; // Replace with your Tag ID
char input[12];
int count = 0;
boolean match = 0;
char state = 0;
void setup()
{
Serial.begin(9600);
pinMode(Ready,OUTPUT);
pinMode(Relay,OUTPUT);
pinMode(Warning,OUTPUT);
}
void loop()
{
digitalWrite(Ready,HIGH);
if(Serial.available())
{
digitalWrite(Ready,LOW);
count = 0;
while(Serial.available() && count < 12)
{
input[count] = Serial.read();
count++;
delay(5);
}
if(count == 12)
{
count =0;
match = 1;
while(count<12 && match !=0)
{
if(input[count]==tag[count])
match = 1;
else
match= 0;
count++;
}
}
if(match == 1)
{
Serial.println("Congratulation Access Allowed");
digitalWrite(Relay,!state);
state=~state;
}
else
{
Serial.println("Access Denied");
digitalWrite(Warning,HIGH);
delay(1000);
digitalWrite(Warning,LOW);
}
for(count=0; count<12; count++)
{
input[count]= 'F';
}
count = 0;
}
}
can this work for multiple cards, while controlling a dc motor
ReplyDelete