Please can anyone help me with my project because its driving me nuts.
I made a project that unlocks my door with one RFID tag and it works flawlessly, but i couldn't add more tags.
what is the best way to do it?
#include <Servo.h>
#include <NewSoftSerial.h>
#define MY_TAG_CODE "3200A0346D5D"
Servo myservo;
NewSoftSerial RFID(2, 3);
String msg;
int locked = 180;
int unlocked = 0;
int trigger = 0;
void setup()
{
myservo.attach(9);
Serial.begin(9600);
Serial.println("Serial Ready");
RFID.begin(9600);
Serial.println("RFID Ready");
}
char c;
void loop()
{
while(RFID.available()>0)
{
c=RFID.read();
msg += c;
delay(1);
//Serial.println(msg);
//Serial.println(msg.length());
}
msg=msg.substring(1,13);
if(msg.indexOf(MY_TAG_CODE)>=0)
{
(trigger = 1);
Serial.println("Card Accepted");
digitalWrite(13, HIGH); // set the LED on
delay(200); // wait
digitalWrite(13, LOW); // set the LED off
}
if (trigger == 1)
{
Serial.println("Door unlocked");
myservo.write(unlocked);
delay(10000);
myservo.write(locked);
digitalWrite(13, HIGH);
delay(200);
digitalWrite(13, LOW);
Serial.println("Door locked");
(trigger = 0);
}
}