Introduction: Making a Better Mouse Trap!
There are a lot of things this world needs at the moment. One of them is a better mouse trap. Mice are getting smarter every day and if we're not careful we'll end up with Planet of the Mice. Luckily, with the help of a Makerbot Replicator 2 (its enormous 410 cubic inch build volume and 100 micron resolution, "100 microns!") we can tackle this problem. And maybe even have a little fun doing it.
The concept is simple:
1 - We set up a real spooky-looking castle. If movies have taught us anything, it's that a spooky house is simply irresistible to people. The louder you scream "DON'T GO IN!" at your TV, the more they want to go in. I don't understand it, that's just the way it is. Mice should be no different. We turn the house into a castle for good measure.
2 - Out with the old, in with the new. A loaded spring just doesn't cut it anymore, we're in the 21st century. We need to throw everything we've got at this mouse. That's why this castle is loaded with an Arduino Uno. Yes that's right, we're talking a jaw dropping 20MHz of raw computational power, 32K of program space and so much more. The mouse doesn't stand a chance.
3 - Hook up crazy sensors and motors into this digital brain to track the mouse's every movement. (ok, so it's a couple photocells and such, but it should work).
4 - When the mouse ventures into the den of evil we slam the gate shut, hoist the trembling mouse to the heavens while calling upon the gods to bring out the moon and some lightning. At this point the mouse will be so traumatized (in a good way) that it will bother you no further. No need to kill it, just send it on its way with a nod of the head and a tip of the hat.
That's the plan.
The truth is, creating this design would not be possible without an affordable 3D printer (aka Replicator 2). 3D printing lets you efficiently explore the inefficient. The 3D printing revolution is not about printing what you normally buy, it's about being able to create what doesn't exist. As playful as this mouse trap is, I'd like to think it's along that vein.
I don't have a 3D printer, although I've been drooling over one for a long time. This Instructable is created to enter the 3D Design Contest at Instructables with the hopes of winning a Replicator 2. This is what I'd like to make if I had one. Voting for it would be much appreciated.
With that said, I've done my best to think through this entire project. I've modeled all components to scale and have confined them to a Replicator 2's build volume. I've tested out the circuits and micro controller code to the best of my ability. I've sourced all electronic components from Sparkfun.com. This is a custom built rig (pulled from the depths of my brain) designed to fit together with exacting tolerances. If you're looking for a bit of adventure, I think this Instructable is for you.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Castle Rundown
Step 2: In More Practical Terms...
Here's what happens:
1) A Photocell sensor is placed in one side of entrance. A Red LED on the other side shines into this sensor. The micro controller watches this sensor and waits for a drop (when the mouse enters the doorway and blocks the LED).
2) When the light again shines on the sensor we assume that the mouse has entered the castle. A servo is activated pulling a string tied to the gate pin which releases the gate. The mouse is now trapped in the Den of Evil.
3) A motor is then activated which drives a set of gears. These gears drive a set of screw hoists on either side of the lift plate which lift the Den of Evil up into the sky (about 2 inches...). The lift plate has an attached LED. When this LED shines into the top lift plate sensor the motor is stopped.
4) At this point a second servo is activated which lifts an attached moon into the night sky.
5) To finish things off, a white (lightning) LED located in the left tower strobes to simulate a truly dark and stormy night.
At this point the Den of Evil can be removed from the lift plate and the mouse let on its merry way.
Two buttons are included to move the lift plate up and down. And two pots are included to trim the gate pin servo and adjust the photocell sensors bias.
-Makerbot Replicator 2
-Mini Metal Gearmotor x2
-Small Servo x2
-Red LED x2
-Push Button x2
-330 ohm Resistors
-10K ohm Resistors
-M/F Wires Pack
-M/M Wires Pack
-Jump Wire Pack
(There's a bit too man wires here, but it illustrates what you need: jump wires to keep the breadboard orderly; M/M and M/F wires)
-Makerbot PLA filament (1 spool)
-Fine Sand Paper
-Hair Clipper Oil
-Needle Nose Pliers
Step 3: Build Plate Legends
You will need to build three plates on your Replicator 2 using the supplied files. Use the corresponding build plate legends to reference all components while constructing. Note that the left/right convention is based on looking at the front/top view of the castle.
These build plates are release under the CC-BY 3.0 license.
Step 4: Cuircuit Legends
Use these circuit legends to help you understand the layout of the breadboard, Arduino and other electrical components. As we go through the wiring, references will be made to these diagrams.
-Circuit Legend 1 shows you what everything on the two boards are and where all the wires go. (don't worry, we'll be going through the wiring step by step)
-Circuit Legend 2 shows you the back of the castle with all the different components
-Circuit Legend 3 shows you an uncluttered view of the breadboard
Step 5: Printing Out the Parts
Because, at the moment, I don't have a 3D printer, I can't give you copious amounts of detail on printing the parts. However, what I do know is that this step involves taking the three STL build plate files I've attached to Step 3 and running them on your printer. Again, I tried my very best to model and orient the parts in a 3D extrusion (with no build support) friendly manner.
If there are problems with the STL files, please drop me a line, I'll do my best to fix them. However another solution would be using the open source application MeshLab to sort things out.
If you can get things printed all fine and dandy, use your knife and sand paper to clean off any overly rough edges.
Step 6: Assembling Your Castle: Getting Started
Start by putting all the components on the breadboard. Use circuit legend 3 as a guide. Don't worry about stringing any wires, just install the components and the black/red jumper wire.
Make sure your pots are centered and oriented as shown in the legend.
As is, those push buttons don't play nice with breadboards. Take your pliers and flatten out the legs so they point straight down (take out the little bend). Now grab a leg half way up from the bottom and twist 90 degrees. Repeat for the remaining three legs then repeat for the other button. Now everyone gets along fine.
Make sure you correctly orient the two NPN transistors. When everything is laid out as the circuit legends show, the flat side of the transistors should be on the right (as shown in the guide).
Make sure you correctly orient the two diodes. The black stripe end of the diode should be on the left.
Resistors have no orientation, they can be plugged in in any direction. As for which values to use where, look at the circuit legend. I have noted the resistor values based on the color stripping.
Note that we'll be assembling from the back, however my left / right orientation is looking from the front/top. That's a little wonky, sorry, but I'm going to stick with my left/right from-the-front orientation. Please keep this in mind.
Now things should be laid out as shown (minus the straight up wires on my rendered breadboard/Arduino).
As we assemble your castle, if you do not know which pieces I'm talking about, please reference the build plate legends from Step 3
Step 7: Assembling Your Castle: Gears, Motors and Servos
Install the main gear and middle gears. Use your knife and sand paper to ensure a nice fit.
The next step requires a tad bit of ingenuity from yourself. The motor shaft needs to fit tightly into the small end of the motor gears. If this does not happen by default, maybe you can use a tiny bit of paper and wedge in some friction.
Now slide the motor braces on the motors/motor gear assembly. Note that the bottom of the braces angle down and the top of the braces are flat. The motors need to slide in to the brace pointing downward (so that the motor gears mesh with the middle gears). It doesn't matter which motor goes with which brace, but once the brace is on, the left brace will only fit in the left mount and likewise for the right.
Next install the servos in the castle towers. As you can see from the image, the right servo lays on its side while the left sits upright. You can dangle the servo wires in the castle tower. Also note the servo head attachment is a half arm (don't screw in these servo arms, just stick them on). Don't worry about the orientation of the servo heads just yet.
Step 8: Assembling Your Castle: Wiring
Now with the castle innards sparse, we're ready to lay some cable.
You may be wondering why I'm using lowly photocells in this design and not something sexy like Hall Effect Sensors for the lift plate sensors (replacing the lift plate LED with a magnet) or infrared emitter/detector at the door. Alas, to keep a short story short, I didn't have the parts (to test things out). So I worked with what I had...
Also, as shown in the diagram, while we're working with the breadboard and Arduino flat on the table, the final position of the boards will be tucked into either side of the castle. So when wiring, keep this in mind and make sure wires are long enough to accommodate this. If need be you can easily join multiple wires together from your wires pack. I've created wire guides along the base of the castle to run wires along and I've also kept the base of the castle towers empty to hold excess wire when the boards are installed. You'll have to lift the main gear to run some of these wires.
My wire color coding is as follows:
Black - ground
Red - power (5v)
Green - to motor
Blue - input to Arduino
Yellow - output from Arduino
Now, on with the wiring! Between my circuit legends and these diagrams, I shouldn't need to say much.
1) Power: Wires go from Arduino 5v/GND to the breadboard.
2) Pots: Pot 1 goes from 29j to A4, Pot 2 goes from 29a to A5
3) Buttons: Button 2 goes from 25h to 8. Button 1 goes from 20h to 7
4) Left Motor Circuit: 16i to lead on left motor, 16d to other lead, 15i to 4
5) Right Motor Circuit: 13i to lead on left motor, 13d to other lead, 12i to 3
Motors Note: you may have to strip then thread the wire through the motor leads and twist.
6) Servo Control: 10i to 11, 10d to 10
(No diagram for the servos, it's pretty straight forward)
7) Left Servo: Using an M/M wire, go from the Black wire on the servo plug to 8h. Red wire on servo plug to 9h, White wire on servo plug to 10h (you can use your M/F wire to extend if it's not long enough).
8) Right Servo: Using an M/M wire, go from the Black wire on the servo plug to 8a. Red wire on servo plug to 9a, White wire on servo plug to 10a.
Step 9: Assembling Your Castle: Wiring Continued...
Now we're going to install the LEDs and photocell sensors.
Note that with LEDs the longer lead is the positive (5v) terminal, the shorter lead is the negative (or ground). Orientation matters, if an LED isn't working first try flipping it around. Photocells have no orientation, they can be plugged in either way.
1) We'll start with the white lightning LED. String the LED in the holder cut out of the upper left tower. You may need to use tape to hold it in place. Use M/F wires. 6i goes to the shorter lead of the LED. 6 goes to the longer lead.
2) Lift Plate LED: 7i goes to the shorter lead of the red LED. Power (to the left of 10j) goes to the other lead. The diagram shows the LED just floating there. That's correct, just leave the LED floating there.
3) Door LED: 6c goes to the shorter lead on the red LED. Power (to the right of 9a) goes to the other lead. This LED is tucked into the right side of the door. You may need to tape it into place.
4) Arduino Sensor Inputs: 3b, 4b, 5b go to A3, A2, A1 respectively.
5) Door Sensor: 5d goes to one end of the door sensor. Ground (to the right of 11a) goes to the other end. This sensor is tucked into the other side of the door. You may need to tape it into place.
6) Top Lift Plate Sensor: 4d goes to one end of the top sensor. Ground (to the right of 9a) goes to the other end.
7) Bottom Lift Plate Sensor: 3d goes to one end of the bottom sensor. Ground (to the right of 8a) goes to the other end.
Just leave those last two sensors floating there as well.
With all the wiring in place you can now organize it as best as possible. Perhaps taping them down into the guides if possible.
Step 10: Assembling Your Castle: the Rest of the Pieces
Now we're going to finish it off (the assembling, that is). My diagrams will keep the sensors floating there and hide all the wiring to make things a bit more clear.
1) Install the screw gears on either end of the main gear. Now test things out by turning the main gear. Add a bit of oil on any gear shaft that gives too much friction (you can also sand the shafts).
2) Next, install the lift plate. Carefully balance it on top of the screw gears then use the main gear to lower it down. Notice that your lift plate LED has been floating there all this time. You can rest it in the holder. You'll have to bend the lead close to the LED at a 90 degree angle for it to fit properly.
Now we need to take a bit of a detour. For all this to work the left motor needs to raise the lift plate and the right motor needs to lower the lift plate. Remember, when I say left motor, I mean the motor underneath the white lightning LED. Now that we have our lift plate installed, we're going to turn on our motor to double check things.
Plug in your Arduino (hooking it up via USB will do it). We don't care about what's running on it, we just need power.
Now take a wire, plug it into the + terminal strip on the breadboard. Plug the other end into 15j. The left motor should turn on. Is it winding up the lift plate? If it is not, swap the two wires plugged into 16i and 16d. Now test again. Things should work.
Now test the right motor. Plug your power wire into 12j. If the plate isn't moving down swap 13i and 13d.
Back on track!
3) Then install the left and rightbrace over the screw gears. They only fit one way. Your top sensor fits into left brace. Feed the wires up through hole in the brace (diagram 3a).
4) Now place the left brace sensor bottom under the left brace. You'll need to tape it in place if it doesn't fit snugly.
5) Install the sensor holder by sliding it into the base of the castle. Place the bottom lift sensor here.
6) Install the sensor holder top and lift plate LED cap on the sensor holder and lift plate, respectively.
7) Take the right servo arm off and tape the moon to it, also take off the left servo arm. You'll put them back on a bit later.
8) Make sure the Den of Evil fits nicely into the lift plate.
9) Install the right and left elastic hooks on the top of the Den of Evil. You'll need to glue these into place.
10) Slide the gate into the front of the Den of Evil. Sand and trim things as needed to ensure a nice slide. A little oil can be used here too.
11) Install the Den of Evil top.
12) Last, but not least, lift up the gate until the notch is level with the top and install the gate pin. Then slide in the breadboard holder. The holder slots in front of the right screw gear brace.
Now sit back and enjoy your results!
Step 11: Finishing It Off and How Things Work
Now we setup the brains.
Get the Arduino talking to your computer. The best place for that info is here.
Once you have that done, download the attached code (rename text file from ".txt" to ".ino") and load it on your Arduino. I've done my best to test this code out (it compiles fine), however, please remember that this is a conceptualized project that I hope to make one day... but have not yet made.
Here is how things works:
1) After loading on the code, when you turn on your Arduino it expects the lift plate to either be aligned with the top or the bottom sensor (this is how it calibrates the sensor). If it's somewhere in the middle your castle will hang in error. You'll know this because the white lightning LED will blink on an off. If this happens, align the sensor and reset the Arduino (using the reset button). Also make sure there's nothing blocking the doorway sensor/LED
2) When the lift plate is in the down position Pot 2 adjusts the pull pin servo. Use this to fine tune your pull. You'll be tying a string from your pull pin to the pull pin servo arm. This will help you tighten things up after settings the pin.
3) When you start your Arduino with the lift plate in the top position Pot 2 now adjusts the door sensor sensitivity. Adjust this pot then block the door LED, the white lightning light now indicates when this sensor trips.
4) Also when the Arduino is started with the lift plate up, the moon servo is lifted up and pull pin servo is set to zero. So for your very first start, put the lift plate up. Now you can attach the moon (taped to the servo arm) to the right servo a little past straight up. Also attach the pull pin servo arm so it's ready to pull (point it at the pull pin).
5) When you are all finished setting up you can press the down button (button 2). The lift plate and moon will now lower. When it reaches the bottom your trap will be armed.
6) Pot 1 always adjusts the sensitivity on your top and bottom plate sensors. If you find your lift plate stopping too soon, or not soon enough, adjust using this.
7) Note that button 1 will raise your lift plate and moon, but will not change the function of Pot 2 (as described in point 3). Pot 2 only adjusts the door sensor when the Arduino is initially started with the lift plate in the up position. After that, it will always trim the pull pin servo.
8) Last but not least, use dental floss to tie the pull pin to the pull pin servo arm. Also string elastics from the Den of Evil hooks (you glued on) and the hooks at the top of the gate. Actually you may only have to string one elastic on the opposite side of the pull pin. Don't make it too tight, we don't want to chop off the mouse's tail! Also, if the pin doesn't pull out easily, you can use a bit of oil here too.
9) Test things out to your hearts content. When everything works as you'd like, you have the enviable job of slotting the two boards (with all that wiring) into the castle. There's a hook build into the wall on the Arduino side to hold it in place. For the breadboard, use the breadboard hook that you installed earlier.
I suppose since we're trying to catch mice we might want to place some bate in the Den of Evil, but I think this castle is enticing enough you don't even need bate. Maybe just some elevator music quietly playing in the background...
If you've actually made it this far, thanks so much for sticking around!
Render of castle on page 1 of this instructable uses moulding meshes created by sizzler and outlet mesh created by anon1 located on Blendswap.
Grand Prize in the
3D Design Contest