Introduction: Automatic Secret Library Door
I've always wanted to have a secret bookshelf door. Who wouldn't? So when I finished my attic, I had the chance to construct a custom bookshelf door that opens and closes by sliding into a space behind the wall, revealing my home office.
But I wanted to go farther than that - I wanted it to automatically activate itself via a secret book or using a special secret knock code. This instructable shows you how I did it. With some modification, you can use the same supplies to make a bookcase swing open and closed like a door.
Time: This project took me months.
Skill level: I'm an experienced woodworker, a novice Arduino programmer, experienced hardware hacker. Moderate to advanced skill level project.
4. Soldering iron
5. Wire cutters and strippers
6. Microswitch (momentary NO/NC)
7. Book you can cut into
8. Various bits of wire, electrical tape, heat shrink tubing, cable organizers
9. Altoids tin
10. Small wood screws
12. 2" fixed caster wheels (6)
13. 1 X 12 wood for bookcase
14. 3/4" bolt
Step 1: Build the False Wall
The challenge was to build an entrance to the far end of the attic, which was triangular. A chimney created a central obstacle and would require the entrance to be on either the right or left. In the first photo, the chimney has been enclosed in sheetrock. With plans for a TV in the middle, both bookcases would be triangular in shape and wouldn't easily swing in or out. The bookcase needed to slide towards the center to reveal the door.
The second photo shows the opening created for the bookcase to slide into.
Step 2: Build the Bookcase
The bookcase is constructed from standard 1 X 12 from the local Home Depot. The bottom shelf is raised to hide the rollers that allow the bookcase to slide. Four straight rollers (two inches, I think) carry the weight and are bolted to the bottom of the bookcase.
I didn't want it to be obvious that the bookcase slides, so I used washers to adjust the wheels so that there was a very slight amount of clearance with the floor. The floor is Pergo laminate, smooth and slick and very low friction. Given that you could load a lot of books into the bookcase, I wanted to make sure it would still move smoothly even with a few hundred pounds of weight on it. I cut a piece of Pergo the width of the distance between the rollers and attached it to the floor so the rollers straddle it. This creates a guide that keeps the bookcase on track when being opened or closed but is low enough not to trip over when stepping through the doorway.
The bookcase is opened and closed using a linear acutator, so I needed some sort of connection to the actuator. The solution was very simple. A horizontal piece of wood sticks out one side of the bookcase like a wagon tongue and connects to the actuator with a bolt.
Safety was a high priority since I figured small children may find the bookcase fascinating. The linear acuator is capable of moving 250 pounds, and I didn't want a small child's hand or body being caught with that kind of force. I rigged two large springs to the tongue that pushes and pulls the bookcase so there is no 'hard' connection between the actuator and the bookcase. You could still get caught in it, but it won't crush you and you can get your hand or body free if necessary. The springs connect to heavy duty eyelets that screw into the main tongue.
The tongue of the bookcase overlays a wooden trolley that connects to the actuator mechanism. The trolley has a hole drilled in it and the tongue has a matching hole drilled as well. A bolt is passed through both to connect them. Knowing that it is not a matter of if, but when, the door fails to open or the power is out and traps the occupant inside, I used a trailer pin that is easily removed, allowing the bookcase to be manually opened. There are also other ways out of the room including a fire ladder and removable wall bookcases on rollers that allow you to climb through to the other room in the case of an emergency.
To keep the bookcase from wobbling when operating, I installed a wooden track, or blade at the top and bracketed it with castors to guide it when opening or closing.
Step 3: Hacking the Linear Actuator
The linear actuator is a Firgelli Automation 40" length track linear actuator capable of a 200 pound force. I'm guessing, but figured if it took more than 200 pounds of force to slide a bookcase on roller, something was seriously wrong.
As you can see from the picture, the actuator is a small motor connected to a gearbox that drives a long rod that is threaded. The rod is encased in the silver aluminum housing and a block rides back and forth on the track and is threaded onto the rod somehow. Think of a nut on a bolt with the block being the nut. It rides back and forth on the track when the bolt (rod) spins. Simple.
The system comes with a manual pushbutton device that uses a 5 pin DIN plug to connect to the motor. Push one button and it moves one way, push the other and it moves the other way.
I took this controller apart and using a voltmeter, figured out which wires went to which button and which pins on the DIN plug. The circuit is simple and requires two momentary contact switches that have normally opened and normally closed positions (NO and NC). When you press a button, it flip flops the voltage from +24 to -24 and the controller inside the motor moves it accordingly. Although it does not appear in these instructions, I spent a LOT of time ensuring I understood how this worked before cutting it apart and hacking into it with my Arduino because the actuator costs about $250 and I didn't want to buy a new one.
I figured an Arduino Uno R3 mega would be a good device to control the door, along with a 2 relay board from sainsmart that had NO and NC positions and a YWrobot piezo electric microphone to listen for secret knocks.
The actuator has limit switches at both ends of the track that automatically stop it even if you keep pressing the button. However, these switches are not adjustable. That is, you can't move the stop point to, say, 10" from the end of the track. If you watch the movie, the 40" travel is more than necessary to open the door. I only needed it to open the door far enough to get to the edge of the bookcase trim, which is fixed in a frame around the sliding part of the bookcase -perhaps 34". In addition, the actuator is a little slow so you don't really want to wait for the bookcase to open, then slide unnecessarily far into the opening before reversing it to close the door.
I figured I could program the Arduino to substitute for the limit switches. First, because the door travels to the far end of the track to close, I simply programmed the Arduino to close the door for longer than it should take. The travel to close it is about 18 seconds, so I activate it for 25 seconds to make sure it gets to the end. When the door is commanded to open, it runs for 18 seconds - just long enough to clear the door opening but not run to the end of the track. If the relay gets stuck, it will simply open the door too far and the limit switches will stop it.
If you watch the video, you'll see that there is no hardware switch to allow you to exit the room. The secret knock is the only way out. If the microphone fails, you'll have to disconnect the bolt and open the door manually. So, I'm adding a "Press to exit" pushbutton that will be mounted on the wall just inside the doorway so the room occupant can command the door to open or close. I'll wire it in series with the secret book switch (which is in the Normally Closed position when stowed). That way, I have an emergency stop and reverse button on both sides of the bookcase.
Step 4: The Arduino Circuit and Software
The requirement for the program was simple:
1. If a secret book (with an embedded microswitch) was pulled, open (or close) the door.
2. If a secret knock pattern is detected, open (or close) the door.
I'd never worked with or programmed an Arduino before, but I did know how to program and found the Arduino to be super easy to work with. It came with tons of short, easy to understand examples that did the exact things I wanted - operate relays and listen to microphones. By experimenting in bits, first with getting the system to just open and close the correct relays, then getting it to listen to knocks, I was able to incrementally build a custom program that operated the door.
Secret book activation
Getting the Arduino to operate the door was easy. I wired a momentary contact microswitch to the Arduino that is in the Normally Closed position when the weight of the book is on it. When you tip the book back, the weight comes off the switch and opens the circuit. The Arduino detects this and checks a door state variable to see if the door is open or closed. This triggers the code to operate the correct relay to open or close the door.
The main loop of the code checks just two things - what is the state of the push button and is that state the same as it was the last time it was checked? If it is, then the book has not been activated, so listen for a knock. If a knock is heard, branch off to a function to listen for more knocks to see if they match the secret code.
For the secret knock code, I am forever indebted to Grathio labs for an instructable for how to build a secret knock detecting lock out of an Arduino. Using the code posted, I was able to re-use the secret knock detection algorithm without having to create one on my own. I owe you guys a beer! The most challenging part of reusing the code was to insert it in my program. I didn't include a programming switch to allow me to change the knock code for simplicity reasons. So, I used the part of their code that listened to knocks, output the values to the serial monitor and then hardcoded them into the program. Not flexible, I understand, but I wanted something simple and straightforward.
I wanted to add safety features so the door could be suddenly stopped and reversed if necessary. If you use the book to activate the door and fail to return the book to it's stowed position within 3 seconds, the door stops. Also, if you pull the book again after 3 seconds, the door will stop. If you pull the book one more time, the door will reverse.
I thought someone besides me might play with the door and accidentally get caught in it. I figured the most likely thing someone would do if they pulled the book and the door started opening unintentionally would be to pull the book again hoping to stop the door. That's what happens.
By requiring the book to be returned to the stowed position within 3 seconds, the person that pulls the book is required to let go of it, meaning their hand is free of the book itself. The bookcase takes 18 seconds to open, so there's plenty of time to get your hand out of the way. I'm mindful that relying on software for safety is a bad idea, so the opening for the bookcase is wider than the bookcase itself. I'm pretty sure a hand could be easily pulled out just by pushing the bookcase backward (into the room) even if the bookcase closed fully. The springs would exert pressure on the hand but I doubt enough to break or trap it permanently. On the room side, the opening is also wide enough to pull a hand out.
Exit push button for room occupant
Since publishing this instructable, I added an exit pushbutton to allow the room occupant to exit easily. Without the exit pushbutton, the only way to close or open the door from the room side is by using the secret knock. I found the push button on eBay for about $20. It is a momentary contact button that has both normally closed and normally open (NC/NO) pins on it. I wired it in series with the bookcase pushbutton. That way activating either button causes the door to operate.
Since pushing the button causes the door to stop, and pushing it again causes the door to reverse, the button is useful when entering and exiting the room. You don't have to wait for the bookcase to fully open or close before reversing it with the button. You cannot interrupt the door opening or closing sequence using the knock, so the button saves a bit of time.
The button will light if you supply it with 24 volts but I don't plan on lighting it up. I'd have to wire up a separate power supply and run the cable to the light and it's not worth it. The button is quite visible and says "Push to Exit" on it. That is sufficient.
Connecting the relay board and microphone
The actual connections for the components are detailed in the software comments but here they are:
1. Relay board: Relay 1 connects to Pin 7 on Arduino. Relay 2 connects to Pin 8. Connect relay board also to the ground and 5v on Arduino.
2. Microphone: Connect to ground, 5v, and OUT pin to analog A0 (zero) pin on Arduino.
3. Book microswitch: Connect common and Normally Closed to digital pin 2 and ground. Doesn't matter which connects to pin 2 or ground.
4. The relays have to be connected to the cable that goes to the DIN plug for the linear actuator. After figuring out how the handheld controller that came with the actuator worked, I bought a duplicate cable with a DIN plug on it so I could preserve the manual controller and have it as a backup in case the Arduino fails.
**Note: the wire colors I show may not be the same if you try to duplicate this!!!! If you wire the controller incorrectly, you will likely burn out your motor controller on your expensive linear actuator!!! You should INDEPENDENTLY confirm this works for YOUR actuator. DO NOT SIMPLY blindly follow this picture***
5. Using the identical DIN cable I bought, I cut the cable to the DIN plug and separated and stripped the wires.
6. I soldered extension wires to the DIN plug wire pins shown in the diagram in step 4 to extend them to the relay board. I used heat shrink tubing (available at Radio Shack) over each soldered wire to keep them from shorting together. I used a small tube for individual wires, shrunk it, then used larger tubing to fit all of the wires inside and heat shrunk that to secure them together. I labeled each extended wire with a piece of tape so I knew which pin on the DIN plug it went to. I triple checked this by continuity testing them using my multimeter.
7. I connected each wire to the output side of the relay board as shown in the diagram, above. I also had to use a jumper wire from the normally open (NO) on relay 1 to the NO on relay 2 and the NC on relay 1 to the normally closed (NC) on relay 2 to duplicate the circuit that the handheld controller had inside it. These connections are screw terminal, so it was easy to connect them.
8. On the input side of the relay board, I ran connectors from the GND and 5V on the Arduino to the GND and 5V on the relay board. I connected the IN1 on the relay board to digital pin 7 on the Arduino and IN2 on the relay board to digital pin 8 on the Arduino.
That's all of the electrical work I had to do. I am in the process of adding one more pushbutton switch inside the room so the occupant can open the bookcase by pushing a button. I will wire that in series with the secret book button. Since that circuit is normally closed (NC), I'll use the NC terminals on the push button I add. When I push it, the circuit will open, the Arduino will detect it, and the bookcase will either open or close, as appropriate. (This is how the secret book button works now.
The code works great and I've included it here but you use it at your own risk. I am not a professional programmer and I take no responsibility for any use you may apply it to.
One odd issue with it is that the very first time after starting the program on the Arduino when you pull the book, nothing happens. The second time, it works perfectly and works perfectly after that. I'm sure there's logic in the loop that's causing that but it's too minor to run down. It only happens the very first time the program executes. Feel free to fix it and post the solution if it bothers you.
Step 5: Installation
After installation, I found that I hadn't allowed enough time for the door to open completely so I added a few more seconds and tweaked it to get it right. The Arduino is so simple to reprogram and remembers the program even when the power goes out, ideal for this application.
So far, the results have been good. In early testing, I had the knock sensor trigger the relays to open the door when I had a loud radio station playing and the DJ was talking. Fortunately, the software has a threshold adjustment and I turned it up quite a bit. That means you have to knock firmly, but so far I haven't had the door open unintentionally. The real test will be when we've had a few movie nights with the surround sound turned up.
Most people won't be able to build their own custom enclosure like I did, but the same techniques could be used to operate a hidden swinging bookcase door. There are a number of plans on the web that show how to build one of these and a smaller linear actuator could be attached to enable the door to be opened and closed by the actuator.
I'm really pleased with the results and unless you know the bookcase slides, you can't tell. If somebody told you there was a secret door and you went looking for it, you'd be able to figure it out, but I'm not concerned with that. This was simply for fun and definitely was a blast to assemble!
We have a be nice policy.
Please be positive and constructive.