Arduino Keypad Door Automation

arduino door pad

[Andrea] just sent us this great student hack he made for his room. He’s constructed an Arduino keypad door lock — without using any proper fastening hardware!

The entire build is made out of scrap parts he had lying around: some DVD’s, a bit of wood, an allen key, a motor and belt from a broken printer, an old hard drive enclosure, and a few power supplies. As you can see the entire setup is held up rather artistically using good old duct tape.

The system auto-locks after 5 seconds, and just in case, [Andrea] has hard-coded in a few safety codes into the firmware to allow him to forcefully open the door — you know, if it malfunctions or something. Not overly confident in his code, he also has it reset every 5 minutes of idling to safeguard against potential memory leaks — probably a good idea! All in all it’s a very cool build, and we have to give him props for not damaging the door to mount it! Down the road he’s also planning on adding a knock sensor using the small speaker that is already part of the circuit, because, why not?

Stick around after the break to see this magnificent contraption that would make Red Green proud.

Comments

  1. “he also has it reset every 5 minutes of idling to safeguard against potential memory leaks — probably a good idea!”

    This falls under the same category of tricks that beat pieces of code into submission instead of using proper engineering like using sleep() to prevent race conditions…

    • matt says:

      When did sleep() become a proper way to prevent a race condition? Although ultimately your point is correct, and reseting the system is a sloppy way to deal with

      On a side note, how can a memory leak possibly occour with this system? I looked thru the code an I dont see it utilizing libc or in any other way it could dynamically allocate memory.

      • smilr says:

        I haven’t looked at the code, so I haven’t a clue if it actually has any memory leaks.
        I’m pretty sure that Oscar was saying that using sleep() was yet another of those “tricks that beat pieces of code into submission instead of using proper engineering”.

        • Greenaum says:

          Nope, that came after “instead of proper engineering like…”, making it “proper engineering”.

          In something like this you just need a few fixed global variables anyway, easy way to keep it simple. Dunno about the libraries but presumably they’re written not to have any annoying interactions.

          • My mistake, I used a poor way of wording that AND I missed a comma. I meant to say that resetting every 5 minutes is just as bad as using sleep() to get rid of race conditions. Instead, proper engineering should be used :)

          • Author here. This project was made during my spare time and since I’m both working and trying to get a phd, said spare time is very little. Since at some point I had some memory leak or [something else] that caused the program to halt after ~30s, and since such problem could render me locked outside of my room, I opted for the easy way out. :-)

      • Without any debugging at some point during development I experienced what I thought was a memory leak. You are correct in stating that my code shouldn’t generate any so after blaming perhaps some of the libraries I was using I simply came out with the dirty reset fix and carried on. Thanks for being thorough and reading through the code – even I thought nobody would as its messy uncommented and poorly readable.

    • Tony says:

      Surely Arduinos have a watchdog timer…

    • defaultex says:

      It’s been in my personal experience that most race conditions arise out of bad sequencing. Majority of the time when I fix someone else’s broken threaded code all I do is just flip a couple lines of code around. Things like incrementing a counter before appending the data it’s counting, operating upon a peeked at item before popping it, and many other things like this that work great in single threaded applications but cause disasters in multi-threaded.

    • Also, I would like to ask an opinion to the commenters who surely sound much more experienced in engineering than I am.
      Regarding this non-graceful solution for example, within a very tiny piece of code that does one thing only: how is a non elegant solution like mine any worse than a proper engineered (yet still tiny and monotask) code? Afterall, once the device is tested working in both cases, if I didn’t ‘confess’ my workaround, there would have been no way to tell which solution I went for.
      So other than aesthetics, why should I do things differently next time?

      • I was going to shoot you an email but maybe using the comments section will help others correct me in case I am giving the wrong advice! In my opinion, a few problems that come to mind when resetting the chip every 5 minutes are:

        – Unnecessary energy consumption
        – Possible errors occurring during initialization (rare, but mostly from hardware)
        – What happens during that initialization and how long does it take? What if the user presses a button just at the right time of the initialization phase?

        In general, proper engineering will give you more robust code that will be easier to extend/reuse and will behave more predictably. In addition to that, designing things well in the first place might actually save you time compared to taking the quick-and-dirty shortcuts! I recommend reading this for more on that topic: http://www.ganssle.com/articles/cyclomaticcomplexity.html

  2. vonskippy says:

    Interior cheap white doors are like what, $45 at Home Depot? Buy a cheap door, do your mod’s on that door, use it while you’re renting the place, store the original door untouched, swap when you leave.

  3. matt says:

    So what happens when the battery dies? I would assume he is locked out/in.

    • matt says:

      After looking at the pictures, I guess he omitted the battery from the schematic and used a AC/DC power supply instead, so I guess my question would be what happens when the power fails.

      • notdave says:

        UPS? shouldnt use much power. if the power is down for much longer than a cheap UPS could serve youve got bigger problems.

        tbh i think the tape is more likely to cause failure/is a bigger concern. i like the ‘buy a second door’ idea. BUT absolutely is a ‘hack’ and i love that about it.

        • Greenaum says:

          The usual way to solve problems like these, is to have the door still locked with a standard key-using lock, but to have the bit the lock catches against, the part that mounts to the door (the catch?) give way if you send it current.

          So you can either open the lock with the key the normal way, or activate the circuit so the catch gives way and the door opens. It’s the way many flats wire their intercom systems, the electric catch is a standard part at DIY suppliers. The lock part is the normal lock the door came with.

          If you don’t want the hassle of carrying keys just in case, give a spare to a friend to look after.

      • Precisely that’s what I did .

  4. nah! says:

    besto solution is a replacement door and storing the orginal one in the basement…

  5. Dax says:

    What about the stains left from the gaffer tape? That stuff is near impossible to remove cleanly once it’s been sitting there for a year.

    • r4k says:

      You are confusing duck (not duct!) tape and gaffer tape. Duck tape will indeed either leave a sticky mess or pull of the paint when it comes time to remove it. A true, quality gaffer’s tape will leave almost no residue after a few weeks, and very little after a year.

      However, I have recently discovered something that might work even better for this application: 3M mounting tape. This is not an adhesive-backed foam tape, but rather a solid material with some very unusual sticky properties. The stuff is remarkably strong, yet can be removed with a quick yank leaving absolutely no residue. I have only been using it for a few weeks now so I cannot give a long-term report, but so far I have been extremely happy with it.

      • jiinkxninngh says:

        Ahh, so here is the lowest common denominator I have heard so much about.

        Duct tape is silver to blend in with the galvanized steel ducts it is intended to seal. Many people have a hard time pronouncing ‘duct tape’. Long after it became quite popular, there was a marketing ploy to take advantage: a brand name called Duck Tape. It was initially sold at places like Walmart to take advantage of people that don’t care about what it is called or what its designed use is. You know, the lowest common denominator of market segments: uninformed consumers.

  6. prof braino says:

    If we put down a layer of painters tape (green or blue) before the duct tape, the adhesive won’t ruin the orifinal finish of the surface. The glue on Duct tape tends to harden and/or get nasty in other ways. The painters tape doesn’t gum up so much. I have cases where the painter tape come off easily and cleanly after about a year.

  7. echodelta says:

    “Quack quack, Duck tape, it’s what keeps America together”. (Garrison Keilor)
    @Indyaner, it’s from Indiana I think.
    It was originally called duck tape in WW2 for it’s waterproof uses in prepping materiel for marine invasion.

    • Greenaum says:

      Surely Jinx’s explanation is the correct one. It’s tape for taping ducts, among other things. The roll of Duck duct tape in the picture above even calls itself duct tape.

      I’m not a military chap, but I’d hope the welding, riveting, and sealing they used back then was good enough without having to tape everything up after.

  8. Sven says:

    I have done some (way way too much) thinking about this particular problem, the solution i came up with for mounting it by unscrewing the handle and inside lock lever and mounting a custom made plate made to fit the holes from those in order not to damage the existing fittings.

  9. Duct Hunter says:

    An old college dorm “get your deposit back” trick involved taking down one’s M.C. Escher posters then filling all the tack and/or nail holes with white toothpaste (after decades of college students living in a given dorm I bet you could work up a nice frothy lather by wetting the walls). Sure is quick and cheap and would probably work to fill small screw holes on the back of a door well-enough for a return of the deposit…

    I also strongly advocate changing the locks of any rented apartment or house and reinstalling the original locks upon moving out. It violates the lease in most cases but IMO it’s one of those “better to ask for forgiveness than permission” kind of things since we can’t know for sure if a previous tenant still has a key.

    Some landlords aren’t very good about re-keying the locks between tenants and others don’t care about your privacy at all and drop by to snoop while you’re out. If there is an emergency the police or fire department don’t need a key and if it’s not then the landlord can call and arrange a time for you to let them in if necessary (in accordance with the law in most places).

  10. ameyring says:

    Another solution for hanging the equipment is to use thin hooks over the door like those door racks use. Some of the equipment will still need to be taped to the door, but most of it can be hung and thus there’ll be less worry of falls from failing tape.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 92,288 other followers