Introduction: An Electronic Door Opener
I live in residence at the University of Toronto, and in my building we have to use key cards to enter and exit our rooms. Like many students around me, I often forget my key card inside my room when I leave, locking me outside!
EDIT: there is a youtube demonstration athttp://www.youtube.com/watch?v=2v30EHG4x_s
So, I decided to design a solution- an electronic door-opener which pulls down the door-handle of my door, allowing me to enter without my key.
If you have a similar situation, you might want to do something like this, but this was more of a fun weekend hack than a real attempt at an implementation, hence the huge quantities of duct tape.
EDIT: there is a youtube demonstration athttp://www.youtube.com/watch?v=2v30EHG4x_s
So, I decided to design a solution- an electronic door-opener which pulls down the door-handle of my door, allowing me to enter without my key.
If you have a similar situation, you might want to do something like this, but this was more of a fun weekend hack than a real attempt at an implementation, hence the huge quantities of duct tape.
Step 1: Parts List
For this project, which was completed over the course of a weekend, I used some spare parts and some new ones, making the overall cost very low.
Power Supply/Regulation
- A 5V regulator (I used L7805)
- 100uF and 50uF capacitors (I used random ones lying around, use whatever you have)
- A 12V 1A wall-wart power supply (don't use less than a 1A supply, the motor needs a lot of current!)
Microcontroller
I used a PIC16F506, any reasonable microcontroller will work.
Keypad setup
- 8 resistors (used for pull-down, I used 10K, anything around that area or less should work great)
- 16-key keypad (any normal matrix-style keypad will work)
Motor setup
- A $4 12VDC motor with a gear on the end
- A 5V relay
Miscellaneous
- A PC speaker (any speaker capable of beeping is fine)
- A prototyping board of some kind, or breadboard
- Duct tape (you know it!)
- Soldering iron, solder, flux, and the like
Power Supply/Regulation
- A 5V regulator (I used L7805)
- 100uF and 50uF capacitors (I used random ones lying around, use whatever you have)
- A 12V 1A wall-wart power supply (don't use less than a 1A supply, the motor needs a lot of current!)
Microcontroller
I used a PIC16F506, any reasonable microcontroller will work.
Keypad setup
- 8 resistors (used for pull-down, I used 10K, anything around that area or less should work great)
- 16-key keypad (any normal matrix-style keypad will work)
Motor setup
- A $4 12VDC motor with a gear on the end
- A 5V relay
Miscellaneous
- A PC speaker (any speaker capable of beeping is fine)
- A prototyping board of some kind, or breadboard
- Duct tape (you know it!)
- Soldering iron, solder, flux, and the like
Step 2: Outline of Operation
The design is very simple. This section will explain the main concepts of the operation of the system.
The keypad is constantly monitored by the microcontroller.
When a key is pressed, the microcontroller beeps the speaker.
If a key code is typed, the microcontroller checks to see if the code is correct. If the code is not correct, the button is beeped at a low pitch, indicating a failed attempt to enter.
If the code is correct, the relay is activated for 5 seconds. The motor is then directly powered by the 12V wall wart, which turns the door handle, opening the door.
The keypad is constantly monitored by the microcontroller.
When a key is pressed, the microcontroller beeps the speaker.
If a key code is typed, the microcontroller checks to see if the code is correct. If the code is not correct, the button is beeped at a low pitch, indicating a failed attempt to enter.
If the code is correct, the relay is activated for 5 seconds. The motor is then directly powered by the 12V wall wart, which turns the door handle, opening the door.
Step 3: Schematic, Notes
The schematic is shown below. I used the 7805 regulator (shown top right) to derive 5V from the 12V supply. The 5 volts delivered by the regulator directly power my microcontroller.
The keypad is a series of buttons with wires connected in a matrix. If the top-right button is pressed, for example, pins x1 and y1 are shorted together. The x pins are the rows of the keypad and the y pins are the columns. Below is a diagram of the keypad.
A word of warning: the open circuit resistance between pins was, in my keypad, actually only about 250Kohms. Initially I used 100Kohm pull-down resistors, which caused the pins to sometimes mistakenly register as being ON when they were supposed to be OFF, which meant that button presses were interpreted by the microcontroller incorrectly. Reducing the resistance of the pull-down resistors resolved this problem.
The keypad is a series of buttons with wires connected in a matrix. If the top-right button is pressed, for example, pins x1 and y1 are shorted together. The x pins are the rows of the keypad and the y pins are the columns. Below is a diagram of the keypad.
A word of warning: the open circuit resistance between pins was, in my keypad, actually only about 250Kohms. Initially I used 100Kohm pull-down resistors, which caused the pins to sometimes mistakenly register as being ON when they were supposed to be OFF, which meant that button presses were interpreted by the microcontroller incorrectly. Reducing the resistance of the pull-down resistors resolved this problem.
Step 4: Code
For reference, I have attached the code I used in this project.
I use the CCS C compiler. There is a free verison out there, which works with many PICs, although I think it does not work with the PIC16F506. The code is provided as a reference to help further understand the design of the machine.
My technique for reading from the keypad matrix is to push pins x1-x4 to 5V, then read the values of y1-y2. Assuming that only one key is being pressed, the y pin which is high will represent the y-coordinate of the buttonpress. Repeat this process pushing y1-y2 to 5V and reading from x1-x4 to determine the x-coordinate.
I use the CCS C compiler. There is a free verison out there, which works with many PICs, although I think it does not work with the PIC16F506. The code is provided as a reference to help further understand the design of the machine.
My technique for reading from the keypad matrix is to push pins x1-x4 to 5V, then read the values of y1-y2. Assuming that only one key is being pressed, the y pin which is high will represent the y-coordinate of the buttonpress. Repeat this process pushing y1-y2 to 5V and reading from x1-x4 to determine the x-coordinate.
Step 5: Demonstration
Here is a youtube video showing the device in operation, and some photographs of the back side of the device and door.
Step 6: Future Improvements
In the future, I plan to make a number of improvements to my device.
Instead of using duct tape, I will use velcro to attach the motor housing and microcontroller board to the door. The duct tape is both inelegant and less secure than velcro, and if the controller needs to be reprogrammed then it can be easily removed if it is velcro.
I have heard that powering a relay directly from the PIC is bad practice. In the future I will use a transistor. In addition, powering the speaker directly from the PIC makes for a very quiet speaker. I will use a transistor, or perhaps op amp, to increase the volume of the speaker.
Finally, I plan to have a "program" switch, which will allow me to program in any code I want into the microcontroller. Right now, I need to take out the pic and program it on my computer in order to change the unlock code. I will implement a programming switch which will allow me to reprogram it to whatever code I like without removing the pic from the installation.
Instead of using duct tape, I will use velcro to attach the motor housing and microcontroller board to the door. The duct tape is both inelegant and less secure than velcro, and if the controller needs to be reprogrammed then it can be easily removed if it is velcro.
I have heard that powering a relay directly from the PIC is bad practice. In the future I will use a transistor. In addition, powering the speaker directly from the PIC makes for a very quiet speaker. I will use a transistor, or perhaps op amp, to increase the volume of the speaker.
Finally, I plan to have a "program" switch, which will allow me to program in any code I want into the microcontroller. Right now, I need to take out the pic and program it on my computer in order to change the unlock code. I will implement a programming switch which will allow me to reprogram it to whatever code I like without removing the pic from the installation.