Unikey: Arduino-enabled keycard access for dorms.
M2M Wires x3
M2F Wires x5
Arduino (https://store-usa.arduino.cc/products/a000066) x1
Stepper Motor (https://www.sparkfun.com/products/13656) x1
RFID Reader(https://www.sparkfun.com/products/11828) x1
Motor Driver (https://www.sparkfun.com/products/12779) x1
Power Source (https://www.adafruit.com/product/798) x1
RFID Tags (if ID card not compatible) (https://www.sparkfun.com/products/9417)
All code for this project is available here.
First, we want to send power to our breadboard so we can power all the elements of our circuit without running out of power ports on the Arduino. Using 2 male-to-male wires, connect the 5v and Ground ports on the Arduino to the positive and negative rails of the breadboard, respectively.
Next, we’re going to set up our reader and make sure we’re able to properly detect an RFID card. Follow this excellent diagram from bildr but instead of connecting pins 1, 7, and 11 directly to the Arduino, plug them into the corresponding rail of the breadboard.
Pins 1 and 11 are the power supply and ground for the reader, respectively. Pin 2 controls reset while pin 1 sends data to the Arduino. Pin 7 controls the reading mode (more on this later). Note that the choice of connecting the reset pin to port 13 on the Arduino is arbitrary. I chose port 4 to keep my cables more organized. Download the code from here onto your Arduino and open the Serial Monitor to view the output when you bring your card near. If nothing is showing up, try changing the read mode or buy an RFID tag to attach to your card (https://www.sparkfun.com/products/9417). Be sure to note the ID that is printed to the console so you can use it later.
Now we can set up the motor. Note you will need to create some way to attach the motor to your door handle and may need to invest in a stronger motor than the one I linked above. You may also need to get a separate power source for the breadboard. We’re going to connect the motor to the motor driver and then connect the motor driver to the rest of the circuit. Your stepper motor should have 4 wires coming out of it, 2 of which control each part of the motor.
Find the positive and negative wires that control the first part and connect them to the ports labelled A. Note the order/polarity does not matter. Connect the second set to B.
Place the motor driver on the breadboard and connect the adjacent +M and GND ports to the positive and negative rails of the breadboard, respectively. Lastly, connect the STEP port to a port on the Arduino (I chose port 2).
Congratulations, you’ve built your circuit! The final product should look something like this.
All that’s left to do is upload the final code (with the right values for the pins and tags) and plug the Arduino into a power source so it can run independent of a computer. The code simply reads the tag as before, checks if it’s the right one, and spins the motor if verification succeeds. As noted above, one needs to connect this motor to the door handle in such a way that it can open the door. I recommend some kind of elastic/string for a handle and a 3D-printed arm for a knob. I’ll add a video of the system working once winter break is over!
UPDATE: Here it is! Special thanks to my floormates for help with the linkages.