Introduction: Arduino Magnetic Combination Lock
This is my first published instructable and there may be many elements of this build that I may be taking for granted. Please feel free to comment if extra clarification is needed as this is a work in progress. This is also a prototype for something much bigger, please excuse the duct tape, shoddy wiring, and beat-up old box.
This project is for a magnetic combination lock using an Arduino, reed switches, and servo motor. The project can easily be manipulated to accommodate other locking mechanisms or modified to make more complex combinations.
The combination is unlocked using a magnet to trigger reed switches hidden behind an article. The reed switches must be triggered in the correct order for the code to enable the unlock function.
For the demo, LED's will be used to display when a reed switch has been tripped. They will also serve as an indicator for the combination, if it was entered correctly or not.
See the video for two test runs of the program. The first trial is a failure indicated by all the lights flashing 3 times. The second trial is a success, indicated by the lights flashing in sequential order.
Step 1: Parts and Pieces
For this exact build, you will need...
- 4 reed switches
- 4 LEDs and appropriate resistors
- 4 additional resistors (I used 100 ohms)
- 1 Servo motor
- 4 diodes (I used 1N4001, but I'm sure specifics are not necessary)
- Sliding door lock
- Box of some type
- A magnet (I prefer the neodymium but don't put your switches to close)
- UPDATE 5/29/16 An external power supply based on your servo size (the 5V supplied by USB may not be enough)
Step 2: Electrical Schematic and Code
Here's the rough diagram of the schematic you will be using. Please excuse any errors in syntax as I am an amateur hobbyist.
Also the code with plenty of comments for modification. In reality the code believes the combination of the triggered switches to be 1, 2, 3, 4 (like my luggage). However, because you can place the reed switches anywhere you want, the combination really doesn't matter. There does need to be a slight delay for each reed switch that is triggered and before a new switch can be tripped, else the Arduino would read the first tripped switch so fast you would never get to the second one. The delay is noted in the code and can be modified for your specifications.
Step 3: The Build Part 1
Seat your sliding door lock (don't forget a small hole for the pin to slide into) and use hot glue to affix the four reed switches to the inside cover of your box. Do not put the switches to close to each other or your magnet may inadvertently trigger the wrong switch. Also drill four holes for the indicator LEDs (PIC 1).
I used a breadboard to simplify the hookups between many of the pins, ground, and switches but this is not necessary (PIC 2 &3).
Step 4: The Build Part 2
Mount the breadboard to the box and attach the LEDs and reed switches.
Step 5: The Build Part 3
Attach servo motor. The specifics on your servo may vary and need adjustments within the unlock function.
A picture could be glued in front of the box with the reed switches located behind key elements within the picture. This will make it easier to remember the loci of the switches.
Remove the LEDs to make your combination truly discreet. Simple trial and error is enough to break the current combination.
Incorporate the lock into a hidden door with access to a secret closet (my next project!)
Enjoy and tweak!