LockBox

by acbonilla1 in Circuits > Electronics

159 Views, 0 Favorites, 0 Comments

LockBox

IMG-9357.jpg
IMG-9356.jpg

For my project in my Physical Computing class in high school, I have created a hidden box to hold valuable items within. It opens on its own, and locks when closed. I am doing this in order to keep certain memorabilia safe at home, while also having a fun place to put them.

Downloads

Supplies

  • Particle Argon Board
  • Breadboard
  • Hall Effect Sensor
  • Small Magnet (I used ~ 1cm)
  • Book (deep enough to hold circuitry within, but has covers that are light enough to lift with ease)
  • Jumper Wires Male to Male
  • Jumper Wires Female to Male
  • 2x Miuzei SG90 Microservos
  • DC Barrel Jack Adaptor
  • 5v Output Power Adapter (Power Supply)
  • X-ACTO Knife / Craft Knife
  • Mod Podge
  • Paint Brush
  • Tape
  • Hook (2.5 cm height recommended)
  • Hot Glue & Hot Glue Gun
  • Ruler
  • Mini Wire Cutter
  • Thin Rectangular Metal Piece (for servo fin, I used 4 cm)

Paste the Pages Together

unnamed.jpg

Before making any cuts to the book, you must first paste the pages together using mod podge with a paint brush. While ensuring that the pages do not make large movements, lightly stroke the sides of the book back and forth with the bush until there is a coating on the necessary surfaces. It might help to get the brush between some pages as you move through this process.

Make sure that there is no mod podge on the top surface of the book's first page. Once this is done, close the book, and apply pressure downwards. This can be done with your hands, but I would recommend using a surface that can push all points of the book's cover. This is so that the pages are properly stuck together while the mod podge dries. Continue this process for at least two minutes, depending on how wet the pages are. Afterwards, place some weighted object that fits the entire top surface onto the book, and leave it there for around fifteen more minutes.

Take Measurements

IMG-8819.jpg

In the process of creating this design, there is a large physical aspect. Our book will serve as the shell for all of our circuitry to reside in. To make sure that the circuitry will fit, we need to draw lines before we start cutting. Using a ruler, decide on an appropriate margin size for your hollowed-out book! You will also need to measure the width and length of a servo (including fin), as a hole will be necessary for one in the future. This is where your servo will rotate to open the book. You will be attaching a servo to that hole in order to open the book using its fin. Above is a photo of how I first drew the measurements for the main hollow body of the book, and in the next photo, you will see my added margin for the servo.

Begin Cutting Your Measurements

IMG-9201.jpg

Cut along your drawn margins. Be sure to do so using your X-ACTO Knife in addition to your ruler. This will allow for a clean interior to be developed, and minimize the mistakes made. Make sure to take breaks while cutting, as this can become a very strenuous action for your hands.

Sanding Process

IMG-9202.jpg
IMG-9237.jpg
IMG-9235.jpg
IMG-9233.jpg

On each SG90 microservo, there are two "platforms" on either side. Using your mini wire cutter, you can remove these attachments. Be careful when doing this, as pieces can fly out and strike you in the eye. Additionally, the plastic of the microservo itself can crack if you do not complete this process in small increments. Make cuts to the bottom of the platform (closest to the body of the servo), and hold the top using a finger in order to make sure the plastic does not fly out. Once you have cleared each platform, sand what remains in order to get a decently flat surface. This flat surface will stop your servo from taking too much space inside of its hole in your book, allowing for a more efficient attachment inside. It also stops the servo from being inclined in certain positions.

Wiring

IMG-9300.jpg

Your wiring might differ from mine, but attached above is a basic outline of my project's wiring. On the very left, there is a rectangle with a Sleeve and Tip. This is a DC barrel jack adaptor. The wiring for this is very specific. If done incorrectly, there will be significant consequences to the Argon (and possibly other attached devices). Do not connect to an additional power source. Your tip should be connected to the power (+) rail, which is also connected to your VUSB pin. The sleeve should be connected to your ground (-) rail, which should also be connected to your GND pin. An AC/DC Power Adapter of 5v output should be attached to your DC barrel jack adaptor. This is how the project will draw its power from a wall that the power adapter is connected to.

Resource for DC Barrel Jack Adaptor

unnamed.png

For more help understanding how to connect to the pins of the power jack, look at the attached image. Credit: https://learn.sparkfun.com/tutorials/connector-basics/power-connectors

Programming

Global Variables

Servo myServo;
Servo myLockServo;

int mySensor = 5;
bool hasLocked = false;
bool opening = false;


Setup Function

void setup()
{
    pinMode(mySensor, INPUT_PULLUP);
    
    myServo.attach(3);
    myServo.write(10);
    myLockServo.attach(2);
    myLockServo.write(170);
    
    Particle.function("beginAB", startServo);
   
}


Loop Function

void loop()
{
    int mySensorState = digitalRead(mySensor);


    if ( mySensorState == HIGH && hasLocked == false && opening == false){
        hasLocked = true;
        lock();
    }
}


Receiving POST Request / Open Book Function

int startServo(String param){
    opening = true;
    myLockServo.write(170); // Make sure book is not locked.
    
    myServo.write(169.5);
    hasLocked = false; // important to place after moving from closed, so starting distance doesn't call lockReset()
    
    delay(2000); // Wait before returning book-opening-servo to open the book.
    myServo.write(10);
    opening = false;
    
    return 0;
}


Lock Book Function

void lock(){
    myLockServo.write(80);
    myServo.write(10);
    hasLocked = true;
}


I attached my two microservos to the ports D3 and D2. Furthermore, I attached my hall effect sensor to D5.

This code receives a POST request, and upon reading it, will call to the startServo function that opens the book. After the program has identified that the book is open by rotating the servo and altering certain variables, it will return the servo's fin back to its original orientation, and begin waiting for the next step.

The next step introduces the hall effect sensor, which will wait for a magnet by sensing the entrance of a magnetic field. Once this occurs, the program will call the lock function. This function rotates the second servo, positioning it over the hook attached to our book, and thereby locking the book from opening. The program enters a state of waiting for a POST request once more.

Combine Software and Hardware #1

IMG-9325.jpg
IMG-9328.jpg

Placing your circuit inside of the book, make necessary plans in order for it to fit. There needs to be enough space vertically so that the wires do not significantly interfere with the closing of the book. You also need space on one side of the book in order to place your locking servo.

The first part of this process will be positioning your locking servo. I placed mine on the end of the book opposite to the spine. I placed it on its longer side, so that there was space for the servo fin to rotate downwards. Its fin should be facing upwards. Directly above this servo should be your hook attached to the book cover. I used hot glue to attach this, but I would recommend a solution that is more durable. The hook is placed here so that once our hall sensor detects a magnet, our servo will rotate downwards, and cling onto the hook above it.

Combine Software and Hardware #2

IMG-9334.jpg
IMG-9333.jpg
IMG-9335.jpg

This next step is to attach our opening servo. Firstly, securely attach your thin, rectangular, metal piece to your servo fin. This will allow for the book to open much easier than with a standard fin. If you have a better option for an elongated fin, then you are open to using that.

Place your servo into the opening we made earlier. The fin of the servo should be facing opposite from the spine of the book. Meaning, the servo is placed on its shorter side, with the wire opening on the top surface. Attach this servo firmly into the hole. I did this with hot glue.

Combine Software and Hardware #3

IMG-9342.jpg
IMG-9337.jpg
IMG-9336.jpg

To attach the hall sensor, choose a comfortable location for your sensor to fit. Keep the other components of your project in mind. Additionally, you will need to attach your small magnet onto a location of the book cover directly above your sensor (the dark node connected to three lines of metal). When the book closes, this magnet should get near enough to the sensor for it to be detected. This distance is something that you will have to test on your own, depending on the magnet.

I attached my sensor to the top right corner of my book. It is leaning to the right, as I chose to use a hall sensor with a potentiometer for the longer body. This way, I could lean the component so that the sensor is closer to where the cover of my book meets the first page. It will be helpful to get the wires connected to this sensor to stick to the base of the book. I used hot glue for this, as well as for attaching the magnet to the cover of the book.

Cutting a Hole for the Power #1

IMG-9205.jpg

In order for your project to be powered, you need access to a wall. As shown earlier, this is through a power adapter that is connected to your system's barrel jack. For the wiring to escape the book and enter a wall, we need a hole.

The first step in this process is to decide where your hole should go. It needs to be placed somewhere that is convenient in regards to the alignment with your barrel jack. Draw a square where you plan to make your hole. The measurements will depend on your plan for the project, but I made mine 1cm x 1cm.

Cutting a Hole for the Power #2

IMG-9206.jpg

Begin cutting into the drawn square. Don't expect to cut the entire hole out. The purpose of this is to just make an outline in the paper for as far as you can. Be extra cautious during this process, as your blade might easily get stuck in the paper.

Cutting a Hole for the Power #3

IMG-9211.jpg
IMG-9212.jpg

You might now realize that it is essentially impossible to carve out a hole from an angle that is parallel to the pages of the book. You will have to pull the book in half (not tearing the pages - simply just pulling one upwards from the "glued" mass).

This allows for us to see how we can complete the depth of the hole. Using a straight edge, begin cutting where you left off; finish the hole on both sides of the book.

Paste Both Halves Together

IMG-9348.jpg

Using mod podge, stick the two halves back together.

OPTIONAL: Use Siri (or Other Systems) to Open the Book

Credit: https://help.ifttt.com/hc/en-us/articles/360053753113-Use-Siri-to-Run-IFTTT-Applets

Using IFTTT, we can create a shortcut on an iPhone to open the book using Siri.

This is done through creating an applet consisting of IFTTT's iOS Shortcut service triggering a webhook service. This webhook would send a POST request to your Argon, thereby opening the book.

Profit

Use your book however you want! I'm not sure how practical it is, but it does look somewhat interesting.