Hello all!
I'm working on an alternative way to access my dorm that doesn't involve my physical key but my university ID card, which is also a HID Proximity (125kHz) Badge. I am using a Duemilanove (ATmega328) with my Mac and Arduino 1.0.5, along with (on the hardware side) a HID RPK40 iClass + Prox (125kHz) + Keypad reader, Hitec HS-55 servo, and a generic magnetic reed switch. My ultimate goal is to present my badge to the reader and (depending on the status of the reed switch) either unlock or lock the door through the servo connected to the deadbolt. (Deadbolt controls lock of handle outside)
I have successfully modified code that I have found online to read my badge, flash the LEDs, and trigger the beeper on the reader. What I have yet to be able to do is get the reed switch and servo to work. I have attached my current code, but will snip relevant sections in-line here.
To start off - my issues with the reed switch. The switch itself is a no-name switch intended for use with security systems. I figure it's the same concept as one I'd buy with an exposed circuit board, so it should work. Please correct me if I am wrong here. It just has two wires coming out. One I inserted in Digital 13 and the other in the GND immediately adjoining Digital 13. I then used this snippet of code...
void checkLock() {
int state = 0;
state = digitalRead(13);
if ( state == HIGH ) {
boolean deadboltLocked={true};
Serial.println("Magnetic Sensor States Deadbolt is Currently Locked");
}
else {
boolean deadboltLocked={false};
Serial.println("Magnetic Sensor States Deadbolt is Currently UnLocked");
}
}
to check the lock's state. Unfortunately, this always returns unlocked, or LOW. I have tried connecting Digital 13 and GND together with a jumper, and even that didn't cause it to read HIGH. Again, this is just how I understand it. Please feel free to correct me. What do I need to do to detect the proper state?
As for the servo, this is the main example that I followed. Arduino Playground - SingleServoExample (and this too http://www.robotshop.com/blog/en/arduino-5-minute-tutorials-lesson-5-servo-motors-3636)
When I upload the sketch using the first example, the servo immediately turns as far as it can (180 degrees) and then until I unplug either the data wire 5V, or GND, it tries to fight to keep turning. In this case, the servo data wire goes into Analog 0.
I have tried this code from the second link with the servo in Digital 8.
#include <Servo.h>
Servo myservo;
void setup() {
myservo.attach(8);
}
void loop() {
myservo.write(25);
delay(1000);
myservo.write(100);
delay(1000);
}
And it behaves as expected. It loops between rotating 25 degrees, then 100 degrees in opposite directions.
What I want is for it to turn the specified degrees upon a valid card presentation, and then essentially power off, and allow for manual turning without fighting the motor so that a key can still be used as a manual override.
Please let me know if I need to clarify, or if you need more details. I have commented quite a bit in the attached sketch, but again, let me know if you have questions. Thanks in advance for any help!
DormMultiProx_ino.ino (7.16 KB)


