Here is the code: //Electronology RFID arduino box. 06/2018. You pass the badge in front of the receiver //and the servo turns to open the door #include #include #include #define uchar unsigned char #define uint unsigned int uchar fifobytes; uchar fifoValue; AddicoreRFID myRFID; // create AddicoreRFID object to control the RFID module Servo myservo; //pins const int chipSelectPin = 10; const int NRSTPD = 5; const int greenLED=12; const int redLED=11; int opclo=0; #define MAX_LEN 16 void setup() { Serial.begin(9600); // RFID reader SOUT pin connected to Serial RX pin at 9600bps SPI.begin(); // start the SPI library: pinMode(chipSelectPin,OUTPUT); // Set digital pin 10 as OUTPUT to connect it to the RFID /ENABLE pin digitalWrite(chipSelectPin, LOW); // Activate the RFID reader pinMode(NRSTPD,OUTPUT); // Set digital pin 10 , Not Reset and Power-down digitalWrite(NRSTPD, HIGH); myRFID.AddicoreRFID_Init(); //Servo myservo.attach(9); myservo.write(0); //leds pinMode(greenLED,OUTPUT); pinMode(redLED,OUTPUT); } void loop(){ uchar i, tmp, checksum1; uchar status; uchar str[MAX_LEN]; uchar RC_size; uchar blockAddr; //Selection operation block address 0 to 63 String mynum = ""; str[1] = 0x4400;
//Find tags, return tag type status = myRFID.AddicoreRFID_Request(PICC_REQIDL, str);
//Anti-collision, return tag serial number 4 bytes status = myRFID.AddicoreRFID_Anticoll(str); if (status == MI_OK){ Serial.print("The tag's number is:\t"); Serial.print(str[0]); Serial.print(" , "); Serial.print(str[1]); Serial.print(" , "); Serial.print(str[2]); Serial.print(" , "); Serial.println(str[3]); if(str[0] == 65 && str[1]==230 && str[2]==53 && str[3]==187){//right card detected //Serial.println("Hello !"); digitalWrite(greenLED,HIGH); delay(100); digitalWrite(greenLED,LOW); delay(100); digitalWrite(greenLED,HIGH); delay(100); digitalWrite(greenLED,LOW); delay(100); digitalWrite(greenLED,HIGH); delay(100); digitalWrite(greenLED,LOW); delay(100); digitalWrite(greenLED,HIGH);
if(opclo==0){//checks if the door is open already myservo.write(150);//open opclo=1; delay(1000); digitalWrite(greenLED,LOW); } else{ digitalWrite(redLED,HIGH);//door is already open digitalWrite(greenLED,HIGH); delay(200); digitalWrite(redLED,LOW); digitalWrite(greenLED,LOW); delay(200); digitalWrite(redLED,HIGH); digitalWrite(greenLED,HIGH); delay(400); digitalWrite(greenLED,LOW); myservo.write(0);//close door opclo=0; delay(1000); digitalWrite(redLED,LOW); } } else{ digitalWrite(redLED,HIGH);//wrong card detected delay(200); digitalWrite(redLED,LOW); delay(200); digitalWrite(redLED,HIGH); delay(200); digitalWrite(redLED,LOW); delay(200); digitalWrite(redLED,HIGH); delay(200); digitalWrite(redLED,LOW); delay(200); myservo.write(0);//close door }} myRFID.AddicoreRFID_Halt(); //Command tag into hibernation }
//Electronology RFID arduino box. 06/2018. You pass the badge in front of the receiver //and the servo turns to open the door #include #include #include #define uchar unsigned char #define uint unsigned int uchar fifobytes; uchar fifoValue; AddicoreRFID myRFID; // create AddicoreRFID object to control the RFID module Servo myservo; //pins const int chipSelectPin = 10; const int NRSTPD = 5; const int greenLED=12; const int redLED=11; int opclo=0; #define MAX_LEN 16 void setup() { Serial.begin(9600); // RFID reader SOUT pin connected to Serial RX pin at 9600bps SPI.begin(); // start the SPI library: pinMode(chipSelectPin,OUTPUT); // Set digital pin 10 as OUTPUT to connect it to the RFID /ENABLE pin digitalWrite(chipSelectPin, LOW); // Activate the RFID reader pinMode(NRSTPD,OUTPUT); // Set digital pin 10 , Not Reset and Power-down digitalWrite(NRSTPD, HIGH); myRFID.AddicoreRFID_Init(); //Servo myservo.attach(9); myservo.write(0); //leds pinMode(greenLED,OUTPUT); pinMode(redLED,OUTPUT); } void loop(){ uchar i, tmp, checksum1; uchar status; uchar str[MAX_LEN]; uchar RC_size; uchar blockAddr; //Selection operation block address 0 to 63 String mynum = ""; str[1] = 0x4400;
//Find tags, return tag type status = myRFID.AddicoreRFID_Request(PICC_REQIDL, str);
//Anti-collision, return tag serial number 4 bytes status = myRFID.AddicoreRFID_Anticoll(str); if (status == MI_OK){ Serial.print("The tag's number is:\t"); Serial.print(str[0]); Serial.print(" , "); Serial.print(str[1]); Serial.print(" , "); Serial.print(str[2]); Serial.print(" , "); Serial.println(str[3]); if(str[0] == 65 && str[1]==230 && str[2]==53 && str[3]==187){//right card detected //Serial.println("Hello !"); digitalWrite(greenLED,HIGH); delay(100); digitalWrite(greenLED,LOW); delay(100); digitalWrite(greenLED,HIGH); delay(100); digitalWrite(greenLED,LOW); delay(100); digitalWrite(greenLED,HIGH); delay(100); digitalWrite(greenLED,LOW); delay(100); digitalWrite(greenLED,HIGH);
if(opclo==0){//checks if the door is open already myservo.write(150);//open opclo=1; delay(1000); digitalWrite(greenLED,LOW); } else{ digitalWrite(redLED,HIGH);//door is already open digitalWrite(greenLED,HIGH); delay(200); digitalWrite(redLED,LOW); digitalWrite(greenLED,LOW); delay(200); digitalWrite(redLED,HIGH); digitalWrite(greenLED,HIGH); delay(400); digitalWrite(greenLED,LOW); myservo.write(0);//close door opclo=0; delay(1000); digitalWrite(redLED,LOW); } } else{ digitalWrite(redLED,HIGH);//wrong card detected delay(200); digitalWrite(redLED,LOW); delay(200); digitalWrite(redLED,HIGH); delay(200); digitalWrite(redLED,LOW); delay(200); digitalWrite(redLED,HIGH); delay(200); digitalWrite(redLED,LOW); delay(200); myservo.write(0);//close door }} myRFID.AddicoreRFID_Halt(); //Command tag into hibernation }
Other purchased cards are not support or shows by rfid sensor. It only shows the value of particular card and key ring .
What to do???
Can we have all Arduino codes please
Here is the code:
//Electronology RFID arduino box. 06/2018. You pass the badge in front of the receiver
//and the servo turns to open the door
#include
#include
#include
#define uchar unsigned char
#define uint unsigned int
uchar fifobytes;
uchar fifoValue;
AddicoreRFID myRFID; // create AddicoreRFID object to control the RFID module
Servo myservo;
//pins
const int chipSelectPin = 10;
const int NRSTPD = 5;
const int greenLED=12;
const int redLED=11;
int opclo=0;
#define MAX_LEN 16
void setup() {
Serial.begin(9600); // RFID reader SOUT pin connected to Serial RX pin at 9600bps
SPI.begin(); // start the SPI library:
pinMode(chipSelectPin,OUTPUT); // Set digital pin 10 as OUTPUT to connect it to the RFID /ENABLE pin
digitalWrite(chipSelectPin, LOW); // Activate the RFID reader
pinMode(NRSTPD,OUTPUT); // Set digital pin 10 , Not Reset and Power-down
digitalWrite(NRSTPD, HIGH);
myRFID.AddicoreRFID_Init();
//Servo
myservo.attach(9);
myservo.write(0);
//leds
pinMode(greenLED,OUTPUT);
pinMode(redLED,OUTPUT);
}
void loop(){
uchar i, tmp, checksum1;
uchar status;
uchar str[MAX_LEN];
uchar RC_size;
uchar blockAddr; //Selection operation block address 0 to 63
String mynum = "";
str[1] = 0x4400;
//Find tags, return tag type
status = myRFID.AddicoreRFID_Request(PICC_REQIDL, str);
//Anti-collision, return tag serial number 4 bytes
status = myRFID.AddicoreRFID_Anticoll(str);
if (status == MI_OK){
Serial.print("The tag's number is:\t");
Serial.print(str[0]);
Serial.print(" , ");
Serial.print(str[1]);
Serial.print(" , ");
Serial.print(str[2]);
Serial.print(" , ");
Serial.println(str[3]);
if(str[0] == 65 && str[1]==230 && str[2]==53 && str[3]==187){//right card detected
//Serial.println("Hello !");
digitalWrite(greenLED,HIGH);
delay(100);
digitalWrite(greenLED,LOW);
delay(100);
digitalWrite(greenLED,HIGH);
delay(100);
digitalWrite(greenLED,LOW);
delay(100);
digitalWrite(greenLED,HIGH);
delay(100);
digitalWrite(greenLED,LOW);
delay(100);
digitalWrite(greenLED,HIGH);
if(opclo==0){//checks if the door is open already
myservo.write(150);//open
opclo=1;
delay(1000);
digitalWrite(greenLED,LOW);
}
else{
digitalWrite(redLED,HIGH);//door is already open
digitalWrite(greenLED,HIGH);
delay(200);
digitalWrite(redLED,LOW);
digitalWrite(greenLED,LOW);
delay(200);
digitalWrite(redLED,HIGH);
digitalWrite(greenLED,HIGH);
delay(400);
digitalWrite(greenLED,LOW);
myservo.write(0);//close door
opclo=0;
delay(1000);
digitalWrite(redLED,LOW);
}
}
else{
digitalWrite(redLED,HIGH);//wrong card detected
delay(200);
digitalWrite(redLED,LOW);
delay(200);
digitalWrite(redLED,HIGH);
delay(200);
digitalWrite(redLED,LOW);
delay(200);
digitalWrite(redLED,HIGH);
delay(200);
digitalWrite(redLED,LOW);
delay(200);
myservo.write(0);//close door
}}
myRFID.AddicoreRFID_Halt(); //Command tag into hibernation
}
Where is the code?
Here it is !
//Electronology RFID arduino box. 06/2018. You pass the badge in front of the receiver
//and the servo turns to open the door
#include
#include
#include
#define uchar unsigned char
#define uint unsigned int
uchar fifobytes;
uchar fifoValue;
AddicoreRFID myRFID; // create AddicoreRFID object to control the RFID module
Servo myservo;
//pins
const int chipSelectPin = 10;
const int NRSTPD = 5;
const int greenLED=12;
const int redLED=11;
int opclo=0;
#define MAX_LEN 16
void setup() {
Serial.begin(9600); // RFID reader SOUT pin connected to Serial RX pin at 9600bps
SPI.begin(); // start the SPI library:
pinMode(chipSelectPin,OUTPUT); // Set digital pin 10 as OUTPUT to connect it to the RFID /ENABLE pin
digitalWrite(chipSelectPin, LOW); // Activate the RFID reader
pinMode(NRSTPD,OUTPUT); // Set digital pin 10 , Not Reset and Power-down
digitalWrite(NRSTPD, HIGH);
myRFID.AddicoreRFID_Init();
//Servo
myservo.attach(9);
myservo.write(0);
//leds
pinMode(greenLED,OUTPUT);
pinMode(redLED,OUTPUT);
}
void loop(){
uchar i, tmp, checksum1;
uchar status;
uchar str[MAX_LEN];
uchar RC_size;
uchar blockAddr; //Selection operation block address 0 to 63
String mynum = "";
str[1] = 0x4400;
//Find tags, return tag type
status = myRFID.AddicoreRFID_Request(PICC_REQIDL, str);
//Anti-collision, return tag serial number 4 bytes
status = myRFID.AddicoreRFID_Anticoll(str);
if (status == MI_OK){
Serial.print("The tag's number is:\t");
Serial.print(str[0]);
Serial.print(" , ");
Serial.print(str[1]);
Serial.print(" , ");
Serial.print(str[2]);
Serial.print(" , ");
Serial.println(str[3]);
if(str[0] == 65 && str[1]==230 && str[2]==53 && str[3]==187){//right card detected
//Serial.println("Hello !");
digitalWrite(greenLED,HIGH);
delay(100);
digitalWrite(greenLED,LOW);
delay(100);
digitalWrite(greenLED,HIGH);
delay(100);
digitalWrite(greenLED,LOW);
delay(100);
digitalWrite(greenLED,HIGH);
delay(100);
digitalWrite(greenLED,LOW);
delay(100);
digitalWrite(greenLED,HIGH);
if(opclo==0){//checks if the door is open already
myservo.write(150);//open
opclo=1;
delay(1000);
digitalWrite(greenLED,LOW);
}
else{
digitalWrite(redLED,HIGH);//door is already open
digitalWrite(greenLED,HIGH);
delay(200);
digitalWrite(redLED,LOW);
digitalWrite(greenLED,LOW);
delay(200);
digitalWrite(redLED,HIGH);
digitalWrite(greenLED,HIGH);
delay(400);
digitalWrite(greenLED,LOW);
myservo.write(0);//close door
opclo=0;
delay(1000);
digitalWrite(redLED,LOW);
}
}
else{
digitalWrite(redLED,HIGH);//wrong card detected
delay(200);
digitalWrite(redLED,LOW);
delay(200);
digitalWrite(redLED,HIGH);
delay(200);
digitalWrite(redLED,LOW);
delay(200);
digitalWrite(redLED,HIGH);
delay(200);
digitalWrite(redLED,LOW);
delay(200);
myservo.write(0);//close door
}}
myRFID.AddicoreRFID_Halt(); //Command tag into hibernation
}
@@electronology4665 thankyou!
@@electronology4665 hey it would also be great if you could make a walkthrough video of making the circuit and installing the card id :)