This post is part of a series I am writing about my senior thesis project. Please check out the other parts of the series to learn even more about my project: Part 1, Part 2, Part 3, Part 4, and Part 5.
One of the common components that can be found in almost any escape room are locks. The reason they are so common in escape rooms is because they can easily fit into almost any puzzle. From standard number locks for math related puzzles to letter locks for word puzzles, the perfect lock exists for almost any type of puzzle. They also work well in escape rooms because they make it easy to hide clues until the time comes for the players to find them. Also, finding the right combination for a lock and finally being able to open it is extremely satisfying.
For my escape room, I knew I would have some form of padlock on the refrigerator with the blood samples. Ideally, I wanted one with individually numbered/lettered wheels rather than a dial since it would be more user friendly. But aside from that, I wanted to have another locked area of the room where I could hide the UV flashlight that would be used to reveal clues in the later portion of my escape room. The UV flashlight would be in a cabinet and I knew I wanted some form of digital lock to go along with the mostly digital puzzles in my escape room. Since most digital locks are expensive, I decided that I wanted to make my own. I thought of many methods for doing this, but eventually decided to use a keypad that would communicate with a magnetic door lock through Particle's publish and subscribe events. This idea was further made plausible when I found an inexpensive magnet lock on eBay.
Using a keypad seemed like a good choice since there is a keypad library for Arduino that has been ported for use with Particle devices. When it came time to choose a keypad, there were three that I was considering: SparkFun's 12 Button Keypad, Adafruit's 3x4 Phone-Style Matrix Keypad, and Adafruit's 3x4 Membrane Matrix Keypad. In the end, I decided on the 3x4 Phone-Style Matrix Keypad for many reasons. First, I thought it looked the nicest and matched with the aesthetic of my escape room. I also liked the fact that it had built-in headers and letters on the buttons in case I wanted to do a word puzzle.
Wiring and programming the keypad was relatively straightforward. There are eight pins on the keypad. Pins one through three are for the columns, pins four through seven are for the rows, and pin eight is an unused pin that can be left disconnected. You can connect the column and row pins to any digital inputs on the Photon (I used pins D0-D6). As for programming, the library takes care of reading key inputs so I just had to write the logic for making the correct code unlock the magnet lock. I also wrote logic to make it so that the players could press the * key to clear their input if they made a mistake and that they had to press the # key to submit their code. You can see the code I used to program the keypad here.
Wiring the magnet lock was slightly more complicated. At first, I tried to power it with a transistor circuit that would convert the 3.3V output by the Photon to the 12V necessary to power the magnet lock. After many frustrating attempts at doing this and almost burning out my transistor, I decided it would be better to just use a DC power supply for the magnet lock. I did not have any 12V power supplies lying around, so I decided to use the 15V power supply from my Wii U. I knew that by exceeding the voltage requirement for the magnet lock that I risked breaking it, but I did not have the time or money to buy a 12V power supply so I tried it anyway. Fortunately, it worked and by combining the Wii U power supply with a PowerSwitch Tail II I was able to control the lock with the keypad. You can see the code I used for the PowerSwitch Tail II to control the magnet lock here.
I decided that I wanted to 3D print a case for the keypad because I knew it would look nicer than just having it in a breadboard. I wanted the back of the case to be able to contain the wiring, Photon with Power Shield, breadboard, and LiPo battery I was using to power the Photon. So I measured all the components and created a 3D model using PTC Creo Parametric, which is my favorite 3D modeling software. I then printed it out of PLA which took several hours. You can see the STL file for my model here. After I printed it, I went to put all the components in only to realize that it was slightly too small and they were not going to fit. Since I was in a time crunch, I used my soldering iron to melt away parts of the PLA until all the components fit. This actually worked pretty well, especially since the parts I melted were in the back and would not be seen, but I would not recommend doing it because it is really bad for the tip of the soldering iron and really easy to slip and burn yourself.
Overall, the keypad magnet lock worked really well. I did have trouble getting the magnet lock to stay in place (since I could not screw it into the cabinet door in the lighting studio) and I had issues placing the spring so the door would pop open, but in the end hot glue and duct tape solved those problems. It worked really well in the flow of my escape room and the players were surprised when they entered the correct code and the door swung open.