Hi All,
I'm new to both arduino and programming..but have a strong background in electronics and computers.
i'm inspired with the rfid door lock project of 'bolsontanker' :
and want to implement with 3 additions.
- add status LED - if access is denied (to pin 11)
- add a switch to open door from inside
- run a light for 30 seconds when door is opened ( pin 10)
my modified code:
/* Basheer Olakara
* Crazy People
* By Mike Cook April 2009
* Three RFID readers outputing 26 bit Wiegand code to pins:-
* Reader A (Head) Pins 2 & 3
* Interrupt service routine gathers Wiegand pulses (zero or one) until 26 have been recieved
* Then a sting is sent to processing
*/
int validSiteCodes[] = {93, 196, 452};
int validSerialNumbers[] = {6032, 15809, 3285};// see if site code and serial number are in the lists...
volatile long reader1 = 0;
volatile int reader1Count = 0;
void reader1One(void) {
reader1Count++;
reader1 = reader1 << 1;
reader1 |= 1;
}
void reader1Zero(void) {
reader1Count++;
reader1 = reader1 << 1;
}
void setup()
{
Serial.begin(9600);
// Attach pin change interrupt service routines from the Wiegand RFID readers
attachInterrupt(0, reader1Zero, RISING);//DATA0 to pin 2
attachInterrupt(1, reader1One, RISING); //DATA1 to pin 3
delay(10);
// the interrupt in the Atmel processor mises out the first negitave pulse as the inputs are already high,
// so this gives a pulse to each reader input line to get the interrupts working properly.
// Then clear out the reader variables.
// The readers are open collector sitting normally at a one so this is OK
for(int i = 2; i<4; i++){
pinMode(i, OUTPUT);
digitalWrite(i, HIGH); // enable internal pull up causing a one
digitalWrite(i, LOW); // disable internal pull up causing zero and thus an interrupt
pinMode(i, INPUT);
digitalWrite(i, HIGH); // enable internal pull up
}
delay(10);
// put the reader input variables to zero
reader1 = 0;
reader1Count = 0;
//digitalWrite(13, HIGH); // show Arduino has finished initilisation
}
void loop()
{
if(reader1Count >=26){
//Serial.print(" Reader 1 ");
//Serial.println(reader1,HEX);
// Serial.println("A");
//Serial.println(reader1& 0xfffffff);
int serialNumber=(reader1 >> 1) & 0x3fff;
int siteCode= (reader1 >> 17) & 0x3ff;
Serial.print(siteCode);
Serial.print(" ");
Serial.println(serialNumber);
reader1 = 0;
reader1Count = 0;
if(IsTagValid(siteCode, serialNumber)
){
digitalWrite(12,HIGH);
}
else
digitalWrite(12,LOW);
delay(2000);
digitalWrite(12,LOW); // Open the door. It's cold out here!
}
}
boolean IsTagValid(int siteCode, int serialNumber)
{
boolean valid = false;
// Determine how many valid tags there are
int validTagCount = sizeof(validSiteCodes)/sizeof(int);
// Loop through the arrays to see if siteCode
// and serialNumber are present
for(int t=0; t<validTagCount; t++)
{
if(validSiteCodes[t] == siteCode &&
validSerialNumbers[t] == serialNumber)
{
valid = true;
break;
}
}
return valid;
}
Components used:
- arduino uno clone with an ATmega8A-PU chip
- HID Reader ((wiegand type - proxpoint plus 6005BGB00 )
- 12v Open Frame Type Actuator Door Lock
- 5v /1A, 12v /3A SMPS power supply
any help appreciated,
TNX ![]()