Arduino Riddle Word Book Lock Box

by sclassing in Circuits > Arduino

2902 Views, 24 Favorites, 0 Comments

Arduino Riddle Word Book Lock Box

BookLock01.png
BookLock02.png
BookLock03.png

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

Screws

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

Mainboard-front.png
ButtonTray-front-back.png

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.

Gerber_PCB_Book Lock.zip


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

ServoLock01.jpg
ServoLock02.jpg
ServoLock03.png

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:



Note: this design was inspired by https://www.myminifactory.com/object/3d-print-motorized-door-lock-6905

3D Print LCD Faceplate

Tinkercad01.png

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

ButtonTray02.jpg
ButtonTray01.jpg
ButtonTray03.jpg

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

BookFront01.png
BookFront01-1.png
BookFront02.png
BookFront03.png
BookFront04.png
BookFront05.png
BookFront06.png
BookFront07.jpg

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

Mainboard01.png
Mainboard02.png
Mainboard03.png
Mainboard04.png
Mainboard05.png
Mainboard06.png

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

Servo01.png
Servo02.png
Servo03.png
Servo04.png
Servo05.png

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

Mainboard01.jpg
Mainboard02.jpg

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

Wires01.png
Wires02.png
Wires03.png
Wires04.png
Wires05.png
Wires06.png
Wires07.png
Wires08.png

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

Battery00.png
Battery01.png
Battery02.png
Battery03.png
Battery04.png
Battery05a.png

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

Switch01.png
Switch02.png
Switch03.png
Switch04.png

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

BatteryMount01.png
BatteryMount02.png
BatteryMount03.png
BatteryMount04.png
BatteryMount05.png
BatteryMount06.png

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

BookLatch01.png
BookLatch05.png
BookLatch06.png
BookLatch07.png
BookLatch08.png
BookLatch09.png

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

InnerLiner01.png
InnerLiner02.png
InnerLiner03.png
InnerLiner04.png
InnerLiner05.png

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

BookPagesEdge01.png
BookPagesEdge02.png
BookPagesEdge03.png
BookPagesEdge04.png
BookPagesEdge05.png
BookPagesEdge06.png
BookPagesEdge07.png
InnerLiner06.png

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

CoverInside01.png
CoverInside02.png
CoverOutside01.png
CoverOutside02.png
CoverOutside03.png
CoverOutside04.png
CoverOutside05.png
CoverOutside06.png
CoverOutside07.png

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

OuterLining01.png
OuterLining02.png
OuterLining03.png
OuterLining04.png
OuterLining04-1.png
OuterLining05.png
OuterLining06.png
OuterLining07.png
OuterLining08.png

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

Components00.png
Components01.png
Components02.png
Components03.png
Components04.png
Components05.png
Components06.jpg

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

Arduino01.png

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.