#include <SoftwareSerial.h>
#include <Servo.h>
SoftwareSerial RFID(3,4);
Servo servo;
const byte taglen = 14;
byte temp[taglen];
String rfidStr = "";
const byte LED = 13;
String tag1="24848484852654968706765663";
String tag2="24848484852654968555250513";
String tag3="24848484852654866524948483";
boolean readTag(){
boolean ok = 0;
if (RFID.available()){
delay(1000);
for(byte i=0;i<taglen;i++){
temp[i] = RFID.read();
}
RFID.flush();
ok = 1;
}
return ok;
}
void setup(){
Serial.begin(9600);
RFID.begin(9600);
pinMode(LED,OUTPUT);
servo.attach(5);
}
void loop(){
if (readTag()) {
rfidStr="";
for (byte i=0;i<taglen;i++){
rfidStr += temp[i];
}
Serial.println(rfidStr);
if(rfidStr==tag1||rfidStr==tag2||rfidStr==tag3){
digitalWrite(LED,HIGH);
servo.write(75);
delay(10000);
digitalWrite(LED,LOW);
delay(100);
digitalWrite(LED,HIGH);
delay(100);
digitalWrite(LED,LOW);
delay(100);
digitalWrite(LED,HIGH);
delay(100);
digitalWrite(LED,LOW);
servo.write(-75);
}else {
digitalWrite(LED,LOW);
}
}
}
#include <Servo.h>
SoftwareSerial RFID(3,4);
Servo servo;
const byte taglen = 14;
byte temp[taglen];
String rfidStr = "";
const byte LED = 13;
String tag1="24848484852654968706765663";
String tag2="24848484852654968555250513";
String tag3="24848484852654866524948483";
boolean readTag(){
boolean ok = 0;
if (RFID.available()){
delay(1000);
for(byte i=0;i<taglen;i++){
temp[i] = RFID.read();
}
RFID.flush();
ok = 1;
}
return ok;
}
void setup(){
Serial.begin(9600);
RFID.begin(9600);
pinMode(LED,OUTPUT);
servo.attach(5);
}
void loop(){
if (readTag()) {
rfidStr="";
for (byte i=0;i<taglen;i++){
rfidStr += temp[i];
}
Serial.println(rfidStr);
if(rfidStr==tag1||rfidStr==tag2||rfidStr==tag3){
digitalWrite(LED,HIGH);
servo.write(75);
delay(10000);
digitalWrite(LED,LOW);
delay(100);
digitalWrite(LED,HIGH);
delay(100);
digitalWrite(LED,LOW);
delay(100);
digitalWrite(LED,HIGH);
delay(100);
digitalWrite(LED,LOW);
servo.write(-75);
}else {
digitalWrite(LED,LOW);
}
}
}