Arduino Riddle Word Book Lock Box
by sclassing in Circuits > Arduino
2902 Views, 24 Favorites, 0 Comments
Arduino Riddle Word Book Lock Box
This is a riddle word book lock box powered by an Arduino Nano. Designed for an escape room, the book lock box will automatically unlock when the gamer enters the correct answer to the riddle.
The book box itself was purchased from Michael's craft store and then modified to hold the Arduino components and locking mechanism. Additionally the book lock box was covered with a leather-looking material on the outside, and black vinyl on the inside.
To build this you will need a 3D printer (for the LCD faceplate and locking mechanism) as well as the ability to do simple soldering.
Supplies
Main components
- Michael's Craft Store book box ( https://www.michaels.com/wooden-book-box-by-artminds/10308287.html )
- Arduino Nano (https://www.amazon.com/gp/product/B0713XK923 )
- I2C 1602 Serial LCD (16 x 2) ( https://www.amazon.com/gp/product/B019K5X53O )
- SG90 Micro Servo 9g ( https://www.amazon.com/dp/B09185SC1W )
- 2 AA battery cases ( https://www.amazon.com/gp/product/B07DCWMMQN )
- 1 rocker switch ( https://www.amazon.com/gp/product/B07DCWMMQN )
- 9 6x6x9mm micro button switches ( https://www.amazon.com/gp/product/B06VY1WJ8Z )
- 2.54mm 10-pin female-to-female flat ribbon data connector, dual row ( https://www.amazon.com/gp/product/B07FZWWGY3 )
- 2 2.54mm DC3-10 pin male shrouded box headers ( https://www.amazon.com/gp/product/B07G26D5ZL )
- 1 2.54mm JST-XH wired 2 pin male connector with female header ( https://www.amazon.com/dp/B096ZVY6Y5 )
- 1 2.54mm JST-XH wired 3 pin male connector with female header ( https://www.amazon.com/dp/B096ZVY6Y5 )
- 1 2.54mm 3 pin right angle header (optional) ( https://www.amazon.com/gp/product/B07LBYDRW5 )
- 2 2.54 mm JST-XH wired 4 pin male connector with female header ( https://www.amazon.com/dp/B096ZVY6Y5 )
- 1 2.54mm 4 pin right angle header (optional) ( https://www.amazon.com/gp/product/B07LBYDRW5 )
- 1 2.54mm 40 pin single row header ( https://www.amazon.com/gp/product/B07CGGSDWF )
- 3/4" x 3/4" x 1" aluminum angle ( https://www.lowes.com/pd/Steelworks-3-4-in-W-x-3-4-in-H-x-8-ft-L-Mill-Finished-Aluminum-Solid-Angle/3058169 )
- 1/4" x 1/4" x 9 3/4" square wood dowel ( https://www.lowes.com/pd/Madison-Mill-Square-Wood-Poplar-Dowel-Actual-36-in-L-x-0-25-in-dia/3041501 )
- (optional) - required if the material used to cover the book is thick - used to raise the hinge screw holes
Screws
- 2 M2 x 12 screws with nuts ( https://www.amazon.com/gp/product/B07PJQC7T6 )
- 4 M2 x 4 screws ( https://www.amazon.com/dp/B09MRXVP84 )
- 4 M3 x 16 screws with nuts ( https://www.amazon.com/gp/product/B07PJQC7T6 )
- 4 M3 x 4 screws ( https://www.amazon.com/dp/B08LQDLV51 )
- 4 M3 Nylon standoffs ( https://www.amazon.com/gp/product/B076CMBKPL )
- 4 battery holder wood screws (approx 5.1mm head x 9.5mm length)
- 4 book latch wood screws (approx 4mm head x 6mm length)
- 2 large servo mount wood screws (approx 7.5mm head x 19.7mm length)
- 2 small servo mount wood screws (approx 5mm head x 12mm length)
Book Covering
- 12" x 12" outer fabric covering
- 8 1/2" x 11 1/4" outer fabric covering
- 10 1/2" x 12 1/2" inner lining covering
- 9 1/4" x 6 3/4" inner lining covering
Order Printed PCB Boards
To make the book lock box, you will need to order 2 custom-printed PCB boards. One PCB board is the mainboard for the Arduino Nano, along with the appropriate connectors. The other board is a button tray that will be mounted into the LCD faceplate.
Simply download the following Gerber files, and upload them to https://jlcpcb.com/quote to place your order.
If you're interested in customizing or changing these for some reason, here are the original PCB designs:
Mainboard: https://oshwlab.com/sclassing/book-lock-mainboard_copy
Button Tray: https://oshwlab.com/sclassing/button-tray
3D Print and Assemble Servo Lock
The servo lock consists of 4 3D printed parts: base, rack, gear, and brace. Print out all four parts and assemble as follows:
- Attach the servo to the base using 2 M2 x 12 screws and nuts
- Attach the gear to the servo using the screw included with the servo
- Extend the gear fully, then insert the rack and retract the gear to slide the rack into the base
Note: the picture above shows the MG90S micro servo (with metal gears) but you can use a simple SG90 micro servo (it's cheaper) - they both have the same form factor.
Here are the original Tinkercad parts:
- Base: https://www.tinkercad.com/things/3BM8Y1gncXi-servo-lock-base-book-lock-box/edit
- Rack: https://www.tinkercad.com/things/lMTvJkevO2s-servo-lock-rack-book-lock-box/edit
- Gear: https://www.tinkercad.com/things/hdehqV83Uc5-servo-lock-gear-book-lock-box/edit
- Brace: https://www.tinkercad.com/things/4A8dqLasD5e-servo-lock-brace-book-lock-box/edit
Note: this design was inspired by https://www.myminifactory.com/object/3d-print-motorized-door-lock-6905
3D Print LCD Faceplate
The book lock box supports 4 to 9 buttons for the LCD faceplate. Simply download the appropriate file below and print it with a 3D printer.
If the faceplate does not quite fit your needs, feel free to copy and edit the original Tinkercad for yourself ( https://www.tinkercad.com/things/iP92hRP63rj-lcd-faceplate-book-lock-box/edit )
Note: This design is a remix of https://www.thingiverse.com/thing:1148903
Solder Button Tray
Solder the buttons and cable connector to the custom-printed PCB button tray that you ordered in step 1. Solder the buttons to the back of the button tray, and solder the the DC3-10 pin male box header to the front (making sure to orient the notch correctly)
LCD Faceplate Mounting
Next we will prepare the LCD faceplate to be mounted onto the front book cover.
- Remove the front cover from the book box by unscrewing the hinges.
- Cut a hole for the LCD faceplate using the dimensions shown above
- Align the faceplate in the hole using the dimensions shown above
- Mark and drill 4 3mm holes in each of the 4 corners
- Using a 6mm drill bit, manually enlarge each hole on the back of the book cover
- With the 4 M3 x 16 screws, super glue all 4 nuts into each enlarged hole
- Remove the 4 screws after the glue dries
- With the 4 M3 x 4 screws, mount the LCD onto the back of the LCD faceplate
- With the 4 M2 x 4 screws, mount the button tray onto the back of the LCD faceplate
The LCD faceplate is now ready to be mounted, but we'll actually mount it in a later step.
Mainboard Mounting
We'll now prepare for the mainboard to be mounted on the 4 M3 Nylon standoffs.
- On the back of the front book cover, place the mainboard that you ordered in step 1 at the location shown using the dimensions above
- Mark and drill 4 2.5 mm holes in each of the 4 corners
- Screw and remove a metal M3 screw into each of the 4 holes to tap the hole with threads
- Screw the 4 M3 nylon standoffs into each of the 4 holes
The mainboard is now ready to be mounted, but we'll actually mount it in a later step.
Servo Lock Mounting
Next we'll prepare for the servo lock to be mounted to the front book cover. The servo lock is mounted with two large screws (near the edge of the cover) and 2 small screws
- Mark the center line of the book cover by measuring 4 7/8" from the top
- Mark a left edge line 1 5/8" from the left edge
- Place the servo lock so that it is centered on the center line, and the base is aligned with the left edge line
- Mark each of the 4 holes
- For the the two holes closest to the edge drill 2.5 mm holes
- For the two holes furthest from the edge drill 2 mm holes
The servo lock is now ready to be mounted, but we'll actually mount it in a later step.
Solder Mainboard
Solder all of the connectors onto the custom-printed PCB mainboard that you ordered in step 1. You'll need to snap the 40 pin header into 2 separate headers of 15 pins each. Also, be sure to orient the notch on the DC3-10 pin male box header correctly.
The picture above shows the optional right-angle headers (which plug in from the side) for the 3 and 4 pin connectors, but you can use standard headers (which plug in from the top) if you prefer.
Note: the PCB in the pictures is slightly different than the one in the Gerber file - the 3-pin servo connection has been rotated so that you can plug in from the left of the board, rather than the top.
Solder Connecting Wires
We'll now solder the connecting wires onto the servo (3 pins) and LCD (4 pins) so that we can connect them to the mainboard. Mount the LCD faceplate, servo lock, and mainboard onto the front book cover so that you can determine the proper wire lengths.
When soldering the wires to the connectors, it's important that the ground pin connects to the ground wire for each component. You can recognize the ground pin on the mainboard as having a square soldering pad (instead of oval). In the pictures above, the ground wires for both the servo and the LCD are brown.
After soldering each wire, be sure to wrap it in electrical tape or (optionally) you can use these heat shrink tubes for a more professional look. ( https://www.amazon.com/gp/product/B01LLBVFGO )
Note: the PCB in the pictures is slightly different than the one in the Gerber file - the 3-pin servo connection has been rotated so that you can plug in from the left of the board, rather than the top.
Solder Battery Holders
The two AA battery holders need to be soldered together so that all 4 batteries are wired in series.
- Lay the battery holders next to each other (end-to-end) with the wires for both coming out from the right
- Take the red wire from the left battery holder and wrap a piece of scotch tape on the end
- Take the black wire from the right battery holder and wrap a piece of scotch tape on the end
- The remaining two wires need to be cut and soldered together as shown in the pictures above
Switch Mounting
Cut a hole in the bottom left of the book box to hold the switch. In retrospect, I wish I had chosen a round switch so that I could simply drill a hole of the correct diameter. The thin balsa wood was difficult to chisel without splitting the wood.
We'll mount the switch in a later step, after the outer and inner covering of the book have been applied.
Battery Holder Mounting
The battery holder will be mounted to the inner back spine of the book box.
- Mark the center of the inner back spine
- Stack printer paper together so that it is 1/8" thick
- Lay the paper against the back spine of the book, and align the battery holder on top of the paper and centered in the book spine
- Mark the 4 drill holes with a pencil
- Use an awl to deepen each hole
- Screw one of the battery holder screws into each hole to tap it for later mounting
We'll mount the battery holder in a later step, after the outer and inner covering of the book have been applied.
Prepare Book Latch
The book latch attaches to the inside outer edge of the book and catches against the servo lock rack when the book is locked. It is made by cutting the 3/4" x 3/4" aluminum angle and drilling 4 holes (2 mm in diameter) for mounting.
- Cut the 3/4" x 3/4" aluminum angle to a length of 1"
- Cut off one edge, leaving 3/8"
- Mark the other edge for drilling 4 mounting holes, punching each with an awl
- Drill each hole 2 mm in diameter
We'll mount the book latch in a later step, after the outer and inner covering of the book have been applied.
Install Book Inner Lining
For the inner lining, you'll need the 10 1/2" x 12 1/2" material that you'll be using to cover the inside of the book.
- Cut the material using the dimensions shown above
- Place the inner lining in the book box, and mark the top edge for each side
- For each of the sides, cut the top edge
- Place the inner lining inside the book box
- Cut a hole in the inner lining for the switch
- Glue the inner lining in place along the bottom of the inside book box but do not glue the edges yet
Attach Book Page Edges
To give the appearance of having pages, we will cover each side of the book box with a printout that looks like the pages of a book.
- Print out the attached BookPagesEdge.pdf
- Cut and trim each of the edges to fit the book box, wrapping the excess inside the box
- Glue each edge to the book box
- With a black sharpie marker, color the top edge of each side so that it will match the inner lining
- Now super glue the inner lining along 3 edges, but do not glue the side of the book spine
Downloads
Wrap Book Cover Lid
For the inside lining of the book cover, you'll need the 9 1/4" x 6 3/4" inner lining material.
- On the inside of the book cover, align the material as shown above
- The edge with the hinge notches should align flush with the material, but all of the other edges should have a 1/4" offset
- Tape the material in place and cut out the hole for the LCD
For the outside lining of the book cover, you'll need the 8 1/2" x 11 1/4" outer covering material.
- Center and glue the book cover onto the outer covering material
- On the inside book cover, wrap each side around and cut each corner at a 45 degree angle
- Glue each wrapped-around edge onto the inside of the book cover
- Glue the inner lining onto the inside of the book cover
- Super glue the edges so that it does not begin to peel away
Wrap Book Box With Outer Covering
For the outside of the book cover, you'll need the 12" x 12" outer covering material. If your outer covering material is thick, you'll also need the 1/4" x 1/4" x 9 3/4" square wood dowel. If needed, you will glue this to the top of the book spine to raise the hinges when you reattach the book cover so that it will close properly.
- Glue one edge of the covering material onto the long edge of the book box
- Wrap the material along the back and outer spine of the book box
- Wrap the left and right edges near the book pages and cut away the excess material
- Wrap the covering material over the spine and cut away the excess material
- Wrap the covering material over the top and bottom of the book spine and cut away the excess material
- Glue everything in place, making sure to super glue any edges so that they do not peel away
- Glue the 4th edge of the inner lining (we skipped gluing it above) onto the inside spine of the book box
Assemble All Components
Finally, we'll assemble all of the components onto the book box, as well as solder the wires for the switch.
- Install the battery holder onto the inner spine of the book box with the wires facing the switch using the 4 battery holder wood screws
- Install the book latch onto the inside outer edge of the book box using the 4 book latch wood screws
- Install the switch onto the bottom edge of the book box
- Solder the red wire from the battery holder onto one of the leads of the switch
- Install all of the components (LCD faceplate, servo lock, and mainboard) to the book cover lid
- Reattach the hinges to the book cover lid and then attach the book cover lid to the book box
- Solder the 2-pin wire to the battery holder and switch as indicated above
- The black wire to the battery holder black wire, and the red wire to the other lead of the switch
- Connect the DC3-10 pin cable between the LCD and mainboard, folding over the excess cable and securing with a couple of twist ties
- Connect the 4-pin cable between the LCD and the main board, making sure to orient the ground wire properly (refer to the brown wire in the picture above)
Upload Arduino Code
The only thing left to do now is upload the code to the Arduino Nano. You'll need to edit the file with your own letter selections and solution. Here is a quick overview of how the solution works.
const char optionChars[NUM_BUTTONS][NUM_OPTIONS] = {
"AXBC",
"ABXC",
"ABCX",
"XABC",
"AXBC",
"ABXC",
"ABCX"
};
const byte solutionIndex[NUM_BUTTONS] = {1, 2, 3, 0, 1, 2, 3};
The optionChars array contains all of the characters that each button will cycle through. The solutionIndex array keeps track of which of those characters are considered the correct letter using a 0-based index.
In the example above, the first button will cycle between A X B and C. The correct letter is X (which is index 1)
The second button will cycle between A B X and C. The correct letter is X (which is index 2)
The third button will cycle between A B C and X. The correct letter is X (which is index 3)
The fourth button will cycle between X A B and C. The correct letter is X (which is index 0), and so forth
Therefore, the solutionIndex contains the proper index for each button that holds the solution letter: {1, 2, 3, 0 ...}
#define SERVO_LOCK_OPEN_POS 700
#define SERVO_LOCK_CLOSE_POS 1580
#define SERVO_LOCK_MAX 2400
Depending on your servo, you might need to tweak the SERVO_LOCK_OPEN_POS, SERVO_LOCK_CLOSE_POS, and SERVO_LOCK_MAX. You can put the application into Admin Mode by performing the following:
- Hold the first button for at least 5 seconds
- Press the first button 5 times in a row
- Hold the last button for at least 5 seconds
- Press the last button 5 times in a row
Once in Admin Mode, you can press the second and next to last button to nudge in increments of 10 the servo lock open and close respectively, printing the values to the serial monitor. This will allow you to fine-tune the values to match your servo.
Finally, you might also need to tweak LCD_START_COLUMN if the text doesn't align over your buttons properly.