Have you ever wanted to keep something safe, but boring old boxes just aren't your style? Have you been dying for a glowing lockbox that's opened by a crystal? Here's the remedy to that.
This is a great way to impress anyone you're willing to show off your treasure trove to, with a feeling like you're opening a chest from a final boss. The glowing frosted panels and the light animations add a layer of fantasy, and will surely make the envious rogue in your party consider a quick stab in the back to loot this from you. Note: Don't let them stab you- getting stabbed hurts.
This Instructable will feature all the steps included into making your own personal Crystal Keyed Lock Box!
The lock is controlled by the optical impedance of a semi-transparent object. Basically, a kind of clear object (which in this case is a rose quartz earring) will trigger the sensor and unlock the box. The setup itself is simple: a laser diode is positioned directly at a photo-resistor. When something semi-transparent interferes with the beam, the photo-resistor picks up values specific to that object. By doing this, you can get a micro-controller to sense when the key is present, versus some other impostor, and trigger a servo-actuated lock.
The design of the box was made in mind to be improved and improvised. I absolutely love the Maker/DIY community and it's ingenuity and resourcefulness, so this is made with them in mind. There are so many improvements to be made upon this design, that I'm always excited to see what people do with a single concept. So feel free to use this as a reference, follow it exactly, or tweak the project; many great ideas can spring from a single one, so I hope you can do just that.
I highly recommend taking a look at the Afterthoughts and seeing my comments what I would change the second time around. I'll post my thoughts on improvements and alternative ideas I've talked over. After all, you want to take my project and make something even cooler and personalized to you!
If this project is successful, I'll more than likely work on an updated, more secure version that'll implement a ton of ideas I've been mulling over!
Step 1: Gathering Materials
The most helpful step before starting a project is making sure you actually have everything you need. This way you can avoid those 4AM trips to the nearest open store to pick up some miscellaneous part you don't have; I've been there too many times to count.
You'll need these materials for the-
Arduino Uno with cable to connect to USB (for programming the Atmega328, so this can be changed)
Hot Glue gun (with accompanying glue sticks)
Safety equipment- Safety Glasses, Face Mask
Disposable Brushes for Varnishing
All the wood I used was Basswood, purchased from Hobby Lobby
3- 1/4" x 1/2" x 24" wooden stick
1- 8" x 24" x 1/8" wooden plank
1- 11" x 14" Plexiglass sheet
1 Can of semi-transparent frosted glass spray
Varnish/Paint (your choice)
A crystal to use as a key (It must be semi-transparent and be able to fit inside the keyhole, so unfortunately, it can't be a large hunk)
Battery Pack 4xAA
28 Pin header (for easy access if the Atmega328 needs to be reporgrammed)
16mHz crystal oscillator
12 pixel Neopixel ring
5 individual Neopixels
2 22pF ceramic capacitors
7805 Voltage Regulator
1000mF 16 V Electrolytic capacitor
Small Laser Diode
SPST rocker switch
10K ohm resistor
3 different colors of 22 gauge stranded wire (I used red, black, and yellow)
Step 2: Preparing the Pieces
When all the pieces are gathered, you can start the basic prepping. The box takes up a considerable amount of time, because cutting through this wood with a utility knife is a crucible of determination. I'm kidding, but it does take a while to do manually.
I planned this box out so the pieces would fit with perfectly with each other. Because this box is built around the frame, the pieces must work around that.
Start off by cutting each of the wooden pieces out, my dimensions are as follows:
(2) 8" x 4.5" Panels (Lid and Bottom)
(2) 8" x 3" Panels (front and back panels)
(2) 4.75" x 3" Panels (side panels)
(2) 5/8" x 8" Panels (front panels on the lid)
(2) 5/8" x 4.75" Panels (side panels on the lid)
(2) 1/2" x 1.5" Panels (keyhole)
(4) 5/8" x 1.5" Panels (keyhole)
(1) 1.75" x 1.625" Panel (keyhole)
(6) 4" Sticks (frame)
(6) 8" Sticks (frame)
(4) 2" Sticks (supports)
(2) 1.75" Sticks (supports for the Keyhole)
For the wood sticks, I used a scroll saw to section those out, then sanded the each of the rough edges.
For the Planks, you can use a utility knife (due to how thin this wood is), or a scroll saw with a blade that won't give a rough cut to the wood. Be warned, the more complex the pieces, the more careful you must be when cutting them out. I had originally broken my lid into two pieces by using too large of a drill bit, and had to work that into the design. I actually ended up liking it, so remember,just because you make a mistake, does not mean it is the end of the world. Mistakes are just opportunities for something different!
Another thing to keep in mind that when you cut the design for the lid and sides, is that you're going to cover the backsides with frosted plexiglass, so the cut out elements will glow. Two additional holes added were on the face for the Neopixel ring, and the power switch.
After cutting the wood, you can cut the plexiglass out. These will fit inside of your frame, and will not be the same size as the face pieces of the box, so be sure you cut accordingly. If you matched the dimensions of the face piece, you would have more space between the wood and it could throw the schematics off. The additional piece you cut will fit to the front of the box to cover the Neopixel ring on the keyhole. Mine was cut to fit over the front face, because the distance between the light and the glass gives it a more diffused look and I liked how it showed on the front of the box.
With the plexiglass cut, you can spray it with the glass frosted to give it that diffused look, plus you don't want anyone sneaking peeks at the cool things you have hidden inside. I used two coats when doing mine.
Before any soldering on the circuit board, there are some electrical components you should prepare beforehand, mainly the Neopixels.
Start soldering the wires on the Neopixel Ring, for positive/negative/Data in/Data out. Give a decent amount of length, to make sure it reaches the board placement. I estimated for this, but it can be changed later if need be.
Next are the individual Neopixels. I got a solder-able pack of five and measured the wire so they could be equally spread out on the inside of the box. There are six solder-joints on each of them: four for the power lines and two for the I/O data lines. Be sure they are oriented correctly when soldering. My dimensions were guesstimated, but if you want to keep the lines minimal, you can do that too.
Once all of the pieces are prepped, you can begin the fun work of assembly.
Step 3: Building the Box
Before you can have a cool lock, you need something to lock. This step will include my method for building the box. Please note that you can work with/around this step if you already have a previously completed box in mind. I built the box out of Basswood, because the store I bought it from was having a sale and there's no way I'd pass that up.
I first constructed the frame with the 1/4" x 1/2" wood pieces. I glued together three rectangles, one for the box base, one for the box top, and one for the lid. Once those are dried, you can attach the four support beams onto the box base and the box top to construct the box.
Once you have the faces cut out and sanded, you can do one or two things at this step- varnish or paint. It all depends on the individual look you want to give the box, but in my case, I varnished it. It took me a while to get the finish that I wanted, but once I was done with the varnishing I was able to attach each of the faces to the box with wood glue. Rubber bands held onto the box while the glue dried to keep the pieces together. The lid was the trickiest because of it's structure, but it was nothing that some zip ties and a few vice grips couldn't fix.
The next step is to attach the frosted back panels to the box, with the frosted matte side facing outwards. I just attached these with wood glue. With the panel on, I was able to attach the last of the 'floating' face pieces.
I chose to abstain from attaching the hinges until the final touches, because it is an awful pain to work with the lid in the following steps.
With the finished faces on, and the box constructed, you can move on to the keyhole.
Step 4: Making the 'Keyhole'
This is perhaps the most integral step in this guide, because it is the coolest function of this project. You must construct a smaller box with the laser, photo-resistor, and Neopixel ring. The placement of the laser is important because your code will be based on it. For good functionality, you must point the laser directly at the photo-resistor so you can get a full reading, and be sure the laser is very well secured. If it is not, the photo-resistor could start to get inaccurate readings and the lock will not work.
I drilled four holes for the wire from the Neopixel ring, and two holes to fit the photo-resistor and the laser. I also notched out a small section for the Neopixel ring to sit so the keyhole could be attached directly to the front face.
Once the box is constructed, Hot glue in the photo-resistor. After that, hot glue in the laser. I recommend hooking it up to power first, so you can make sure the beam is directly on the photo-resistor. With these two components set in place, you can thread the wires to the Neopixel through the holes and glue it in.
Step 5: Programming
For this project I used an Arduino Uno to upload code to a Atmega328. This section will be very heavy with code, but I'll point out the important things that are needed to change for each individual project. I use the pins and variables as follows
A0= Photoresistor- defined as lightPin
threshold = The value of the laser interference. Find the value it sits at without interference, then go about 10 integers down, just to be safe. When it senses anything below this value, the code will check if it's the key or not.
UpperKeyThreshold and LowerKeyThreshold = The upper and lower limits of the key. I prefer this method because if you use an organic material, such as a crystal, you're going to get a lot of impurities which will make the positioning of the crystal a lot harder to work with. This way, you can test the key to find a range you're comfortable with. Remember, the smaller the range, the harder it will be to unlock the box with a specific object, and the larger the range, the easier it will be to use other objects to get into the box.
The first thing you want to do it test the box to find the specific values. I recommend the program Arduino supplies, because it's quick, easy, and efficient to use. Once uploaded, connect the box as shown in the diagram on the website. Once it's hooked up, and the laser given power, you can then test for your variables. This way you can test the position you want your key to be in, and find the values to match. Once you find them you can move on to the actual program.
Rather than blast the guide with my code, I'll attach it to this step as a file, which you can download and modify as you see fit.
You can't use the regular servo library in conjunction with the neopixel library due to some data stream conflicts between the two; that's why Adafruit made a servo controller library that would work with it. The article included is a neat read on the reasoning behind it, so there's information about it in the link if you're interested.
Step 6: Soldering in the Hardware
For this section I didn't take any pictures of the process because in all reality, that would be a mess to follow. Instead I've opted to draw out what I have connected and where. I've also included a picture of my messy wiring, but it's intended as a reference, not exactly how you should follow it.
Note: I did not include the +5v and GND connections for the Laser, Servo, or Neopixels to keep the diagram clean.
Another important thing to note is that Adafruit recommends adding a 1000uF capacitor in parallel with the power supply for the Neopixels- This helps avoid the problem of damaging a Neopixel from a surge of power on startup.
Personally, I place the 28 pin header first, so I can visualize better placement for the rest of my hardware. I then place my power supply and voltage regulator.
The photo-resistor has a tricky position if you, like me opted out of using wires and connected it directly to the breadboard. This will attach the keyhole and the circuit board, so be careful from when soldering the two together.
For the switch, you will have to place the switch outside and run the wires through the hole to solder them onto the switch. After this is done you can plug the switch onto the box.
I used the free trial period of CircuitLab to draw the schematic included.
Step 7: The Lock
This is my least favorite section, because I have had the most trouble with it. My original intentions were to 3D print a servo actuated lock at my University, but unfortunately, due to the winter break, I was unable to. I tried many different methods with the materials at my disposal, but wasn't satisfied with the result from any of them. A friend recommended that I make the lock just a simple hook latch onto the lid of the box, and after I experimented with it, it worked.
In the end, after mounting the servo, I was able to attach a small hook I cut out of wood onto the servo, using hot glue. The wooden hook latches onto the small shelf I added in the lid of the box. It's a very easy and simple lock to make. If you're interested in better locks, please look at the Afterthoughts section, as I go over some other options I could have gone with.
When making the lock, be careful to test the lock and unlock positions. If you write a servo to go to a certain angle and the latch prevents that, there will be issues. So to be safe, just make sure that the parts fit.
Next up, are the final touches.
Step 8: Final touches
With the circuitry out of the way, you can fit everything in the box You can hot glue the Keyhole to the box, then position the separate Neopixels in a way that they will reflect a good amount of light on the panels. Once each is positioned, you can hot glue them in place. I positioned my board on the wall to save as much room inside the box as possible.
This step you can add the hinges, because you shouldn't have to deal with the inside components any longer.
The final step is to attach the face plate for the Neopixel ring. I attached mine with screws I had left over from my hinges.
Step 9: Afterthoughts
In this section I will be reviewing other options I had considered and additional elements to add to the box. A reason I did not do a lot of these was the time constraint and financial constraint.
Lock: I would have much preferred a more secure locking system, but due to my limited budget and my inability to 3D print the servo actuated lock I had in mind, I was unable to. I would have made a actuator that pushed a pin between holes in the lid and box to secure the two together. I was also recommended the possibility of a solenoid lock with the same general idea.
Box: If I were to redo this project I would love to use a prettier wood that would have looked amazing varnished, or done a nice paint job on the box itself. The basswood just doesn't have as organic of a look as I wanted, it looks more processed.
Circuity: I should have placed some capacitors near the 7805, just for additional safety precaution.
Power Supply: Because I wanted easy accessibility I used a battery pack instead of a DC plug, which admittedly would have been easier to manage; the battery pack method also limits the time it can be kept on.
Neopixels: I would have loved to spend more time making a really neat amount of animations for the box, instead of the simple basics, because the versatility of the Neopixel is incredibly neat. Maybe next time include a strip instead of individual pixels to make it brighter.
If you have any questions, please don't hesitate to post below in the comments or send me a message!
This project has taken a lot of work, but I'm proud of it and am excited to see what comes next!