latches -- the mechanical kind

I had the idea to embed a Christmas present in a box with some sort of internal latch that prevents the box from being opened unless the following conditions are met:

  1. date >= December 25
  2. box is in a certain location as reported by onboard GPS
  3. box is proximate to a similar box given to another friend

It will be a ton of fun to build these two boxes with their little embedded Arduinos, and I don't think the software will be too hard. What's giving me grief is my inability to imagine how to build the latch mechanism, which must:

  1. securely lock the box from the inside under electronic control (obviously)
  2. unlock the box when the right signal occurs
  3. keep the box locked if/when the external battery is replaced.

Has anyone done anything like this before?

Many thanks for the help.


I did a search for electromagnetic locks and got a lot of hits. Shlage makes some and here's a link: Locknetics .

I imagine they are normally controlled through a relay since they are 12 volt. They may be heavier than you want. I guess you could also use a servo to drive a pin into (or out of) a mortise if there isn't a need for a heavy duty lock. Or a stepper with a cam on the drive gear to do likewise. Or rack and pinion. Or even a stepper attached to the knob of a standard deadbolt.

Somehow I think the electromagnetic lock would end up taking the least amount of time. The others involve other engineering efforts.

You could just mount a pin to the actual servo arm, mount the servo so the pin engages and disengages with a slot in the lid. If someone pulls really hard it'll break, but that's true of any other piece of the box I guess.

Fun idea.
But if its very secure I would think of a hidden way to unlock it if it all goes wrong unless you want to break it open and undo your work.
Maybe a couple of the screws as contacts for power to override the lock?


This is really cool :slight_smile:

If you make one please post some pics :slight_smile:

If you enjoy re-purposing things you could use the tray eject mechanism from a discarded cd/dvd drive to unlatch a pin holding the lid closed. or link the mechanism to the box lid and have it open automatically when the box is moved or shaken after the correct time has expired

Have fun :slight_smile:

Heres a cheap chinese deadbolt :

I seem to recall a very similar project (at least the timed lock release part) on these forums before--perhaps in a thread also about real time clocks?

Would be worth searching the forums.


Dear friends,

I am grateful for the enthusiastic response and the helpful comments. My current vision is for an LCD mounted on the box to provide vague clues about how to solve the puzzle and open the boxes. For example, a button press might cause the following to be displayed:

** Distance: 120km**
** Time: -11d**
** Proximity: unknown**
__ Access denied__

"Access denied" because the box is still 120km away from my "magic" location, Christmas is still 11 days away, and the twin box is not detected nearby. The recipient must decipher these clues to (legitimately) get the goodies inside the box, namely the Arduino and the GPS unit!!

@chilinski: I think that's probably the kind of lock I'm looking for, but hopefully I can find one that is smaller and consumes less power? Also, what happens to those when the power is disconnected (because the battery died?)? Do they still latch?

@macegr: I thought of using a servo to move a pin, but I'm very klutzy with mechanical design of this type and feel certain that I'd make a mess of it and get the pin stuck at exactly the wrong time.

@Gordon: The idea of having to get my saw out to extract the goodies from my box worries me too. Rev 0 of my projects typically contain a bug or two! Since I am a software guy, I had thought of inventing a secret morse-like access code that one could tap in using the button, but your "magic screw" idea is pretty cool and more failsafe.

@gnu_linux: OK!

@mem: What a good idea to make some use of the mechanisms lying dormant in the pile of old CD drives I have! I'm going to have to give this serious thought! That would be awfully impressive for the box, after a month of dormancy, to suddenly whir to life and dramatically open a drawer. It would almost be like a scene from a movie!

@MikMo: I may buy that deadbolt just to play with. Thanks for the tip!

@Phil: I dug around through the forums but can't find anything terribly apropos. It think it's amusing that guys like me post one-of-a-kind questions in the "Frequently-Asked Questions" forum. If you can't find your answer in one of the 1140 topics already posted there, then by definition it isn't a FAQ! :slight_smile:

Another concern I'm starting to have is power. I had originally thought that I would design the box to be almost always asleep, waking for only a few seconds to read the GPS and generate the LCD report after a button press. But then I realized that while asleep, the internal timers do not work (duh!) and so I won't be able to tell if it's Christmas without hooking up some kind of real-time clock chip, which consumes power of its own. It will destroy some of the mystery of the box if the recipient has to change the batteries four or five times or plug it in or lug around a 5kg battery.

Thanks for reading my ramblings.


A reasonably large NiMH, Li-Ion or LiPo battery should do the trick :slight_smile:

The Arduino consumes very little power and you can clock it down if you need to

Look at page 306 of the ATmega168 datasheet and so on


Go the GPS things work indoors?

My satnav needs to "see" the sky and must be mounted in the car accordingly.

Just a thought.


@gnu_linux: I'm heading up to Fry's today to investigate battery options. I hope I can find a solution that can keep an Arduino running for a couple of months -- or at least its time clock -- with occasional bursts of GPS and XBee (?) activity when the user presses the button. Maybe it would be nice to display battery power remaining as well.

@BigMike: You are quite right that GPS requires being outdoors. However, my intended recipients are outdoors-y types, and (hopefully) smart enough to eventually figure out that when the LCD displays distance: unknown or distance: no signal that they have to take it out. Also, I think the GPS module will necessarily be visible, so that will be an additional clue.


Mikal has a wide selection of rechargeable batteries

To keep it running a couple of months you might need a large Li-Ion or LiPo battery or a 12V lead-acid battery

Remember Ni-Cd batteries suck!

Shop around :slight_smile:

What a great idea! I can only imagine getting one of those and laying awake at night thinking up the next thing to try.

Be careful that no one involved will think it's dangerous!

My solution to the power problem would be a hand crank to charge up the battery again when it's low. Grab the mechanism from a hand crank flashlight or lantern. Since they will be outdoors with it a lot anyway, you could also use a small solar panel to power the whole thing. No battery at all.

The addition of the GPS means you won't really need a real time clock chip, just grab the current time out of the GPS data stream.

This is kind of what I mean as far as using a servo as a latch mechanism. In the drawing below, I've simply cut off part of the servo wheel and use it as a cam. Your code rotates the servo 90 degrees to move the cam out of the slot in the block attached to the lid. It's hard to get any simpler, I think.

You could even use several cheap micro servos from DealExtreme, and have the cams at different angles, so the person unlocking the box needs to figure out the correct code to get all the servo cams lined up.

Walterr-- Thanks so much! Your tip about using the GPS for time solved the last "tricky" problem still blocking me from actually starting to go buy stuff. Of course! Because I no longer have to rely on the internal clock to keep time, I can put the Arduino into a very deep sleep (or even turn it completely off!) in between user interaction events. Assuming my circuit consumes ~100mA and each "event" lasts only ~3 minutes, I think I calculate that a 6V 5Ah lantern battery should be able to power ~1000 of these events. I imagine that should be plenty. And if not, that hand crank idea is excellent too!

Be careful that no one involved will think it's dangerous!

I'm a little worried about that myself. My recipients will be traveling overseas by air at Christmas. Hopefully my little un-unlockable boxes won't trigger any security alerts!

I've been playing with the little Dallas One-wire thermometers recently. They are cheap. Maybe I'll add a requirement that the temperature be above 30C to unlock the box. Not too easy outdoors at Christmas in that part of the world! :slight_smile:

Thanks, all,



Thanks for the drawing! That does indeed help my poor brain visualize how this could be done, and I agree that it could hardly be simpler! (What did you use to draw that, if you don't mind me asking?)

Thanks again,


That's Google Sketchup, you can download and use it free. Takes a little getting used to, but they have tutorials you can follow. I much prefer a real CAD program for anything that has to be dimensionally accurate, but can't deny Sketchup makes fast work of roughing out 3D ideas.

I think I'd really worry about the security thing. Imagine the box being XRayed and the federales seeing electronics in there. They won't even ask to open it...they'll let their robot do it his way. I'm serious; I think air travel with it could be a problem.