Leprechaun Trap!
by MrSteier in Living > Pranks, Tricks, & Humor
1297 Views, 2 Favorites, 0 Comments
Leprechaun Trap!
![IMG_0660.JPG](/proxy/?url=https://content.instructables.com/F1M/MO3A/ILZG4DTM/F1MMO3AILZG4DTM.jpg&filename=IMG_0660.JPG)
![Leprechaun Trap](/proxy/?url=https://content.instructables.com/F5U/2GRP/ILZG4F9Y/F5U2GRPILZG4F9Y.jpg&filename=Leprechaun Trap)
March 17th comes around once a year and trapping a leprechaun is always on my families' to do list. We are designing a project that will lure in a sneaky little green gold digger and trap them in their unquenchable lust for gold. We look forward to trading our fake gold coin for the leprechaun’s freedom and real gold pot at the end of the rainbow.
After finishing the Arduino beginners guide, we are going to use the tools from the ARDX Arduino Experimentation Kit purchased from Adafruit.com.
My daughter and I are working on this project together, and we were looking for a way to truly catch those little magical wonders. We designed a small “drop” trap held up with a simple bar brace and drop technique. The brace connects to a DC motor and Arduino by a small string. We will be using the photoresistor as our input and a gold coin as a trigger. When the miniature green suited gold digger attempts to pull the coin off the photo resistor, the DC motor will be activated from the light and BAM, it’s a trap! Lucky for us, we will have successfully captured an unlucky leprechaun.
In review:
-We are building a leprechaun Trap.
-The leprechaun will trigger his (or her, are there female leprechauns?) own trap by their greed.
-The trap will be primarily composed of Arduino Uno, DC motor, photoresistor, fake gold.
-Start dreaming of all the ways you will spend that pot of real gold.
Creativity and family bonding highly encouraged but not required.
Materials and Supplies
![IMG_0639.JPG](/proxy/?url=https://content.instructables.com/FV1/FSMV/ILY0S7XQ/FV1FSMVILY0S7XQ.jpg&filename=IMG_0639.JPG)
![IMG_0636.JPG](/proxy/?url=https://content.instructables.com/FW5/3MIH/ILY0S7X7/FW53MIHILY0S7X7.jpg&filename=IMG_0636.JPG)
Hardware/Components
These components are found in the ARDX Arduino Experimenter's Kit
- Arduino Uno
- 9V Battery holder
- Breadboard
- USB cable
- 1 - Photo Resistor (input)
- 1- Green LED (output)
- 1 - DC Motor (output)
- 1- 560 Ohm Resistor (Green-Blue-Brown)
- 1- 10k Ohm Resistor (Brown-Black-Orange)
- 1-2.2k Ohm Resistor (Red-Red-Red)
- 1- Diode (1N4001)
- 1- Transistor (P2N2222AG) (TO92)
- 12 - Wires
Additional Hardware
- 9V Battery
- Box (some container, for example, shoe box, tissue box, food storage container)
- String
- Adhesive Tape or Adhesive material
- Rod (pencil, dowel, stick, or series of magnetic rods)
- Food Storage container
- Paper or Cardboard
Tools
- Hot Glue Gun
- Drill (power drill works best)
- Drill Bits (various sizes depending your needs)
Software
- Computer
- Arduino IDE
- USB cable (Computer to Arduino, included in the ADRX kit)
Decorative Craft Supplies
- Gold Coins (fake of course, if you have real ones you may not need this trap)
- Gold Spray Paint (if you don’t have real gold but need to make someone think you do)
- Coin or small round disk that can be painted
- Construction Paper
- Stickers
- Glitter
- Markers/Crayons/Colored Pencils String
Setting Up the Photo Resistor
![CRIC-09 Light Photo Resistors ARDX_bb.png](/proxy/?url=https://content.instructables.com/FOA/L9KP/ILXYMISL/FOAL9KPILXYMISL.png&filename=CRIC-09 Light Photo Resistors ARDX_bb.png)
![IMG_0640.JPG](/proxy/?url=https://content.instructables.com/FCL/WL1Y/ILY0S7XX/FCLWL1YILY0S7XX.jpg&filename=IMG_0640.JPG)
The first step will be to set up our photoresistor according to the ARDX Arduino Experimentation Kit. This experiment is CIRC 09 in the kit, and we will be setting it up identical to the guide.
You will need to be certain that you have the correct resistors for the Ohm value in the right positions to balance the circuit adequately.
Next, we will load the code for the photoresistor to ensure our circuit was properly built and functional. The CIRC-09 code is at this link here.
After you load this into the Arduino IDE, test your light sensor a few times to be confident it is working.
We are now going to modify the code by changing the loop so the photoresistor acts as a light activated switch, like a nightlight. You can find this code on the CIRC-09 page in the ARDX guide or included below.
Nightlight:
Rather than controlling the brightness of the LED in response to light, let’s instead turn it on or off based on a threshold value. Change the loop() code with;
void loop(){
int threshold = 300;
if(analogRead(lightPin) > threshold){
digitalWrite(ledPin, HIGH);
}else{
digitalWrite(ledPin, LOW);
}
}
Replace the Output With DC Motor
![CRIC-09 and 03 Light Photo Resistors with DC Motor ARDX_bb.png](/proxy/?url=https://content.instructables.com/FQR/RZ22/ILXYMISG/FQRRZ22ILXYMISG.png&filename=CRIC-09 and 03 Light Photo Resistors with DC Motor ARDX_bb.png)
![IMG_0641.JPG](/proxy/?url=https://content.instructables.com/F5Q/MCGD/ILY0S7Y3/F5QMCGDILY0S7Y3.jpg&filename=IMG_0641.JPG)
In the previous step, we set up our photoresistor according to the ARDX Arduino Experimentation Kit . This is CIRC 09 in the kit and we will be set it up identical to the guide.
In this step, we are removing the green LED output from our circuit. We will be replacing it with the DC motor as the output.
We are referring to CIRC-03 in the ARDX Arduino Experimentation Kit . We will be adding the CIRC-03 breadboard layout to our current layout for the photoresistor.
Be certain that you are using the correct resistors in each situation in order to balance the circuit.
At this point, you should be able to run your “Night Light Code” through the photoresistor to use light as the trigger for an on and off switch.
We will modify our code later to match our syntax for a DC motor. This will be done in the software phase of our leprechaun trap.
Software and Code
![Capture IDE Leprechaun Trap.PNG](/proxy/?url=https://content.instructables.com/F0J/ORR4/ILXYMJJX/F0JORR4ILXYMJJX.png&filename=Capture IDE Leprechaun Trap.PNG)
In this step, we will be uploading the code to our Arduino. The code is organized to use the photoresistor as our input and the DC motor as our output. We want the leprechaun to grab the coin and trigger the light threshold set by our programmed code to turn the DC motor “on.” Once running the DC motor will wind up the string attached to our brace and drop the lid of our trap down on the leprechaun.
In this step, you will need the Arduino IDE installed on your computer. You can follow the link here to find and download the software. This is what we will be using to upload our code to our board in order to program our trap.
You will also need the USB cord for your Arduino. Connect this cord to both your Arduino and your computer. This will be your “rainbow” magically sending the code from your computer and the IDE to the Arduino.
This is the code we will be using. You can copy and paste the code below into the IDE. Notice the notes below to help you understand how the program runs. This code is a modification of the CIRC-09 code from the ARDX. We changed the Pin from a lightPin to a motorPin in order to keep our syntax accurate.
/* * A simple program that will sense light and turn on a DC Motor * */
//PhotoResistor Pin
int lightPin = 0; //the analog pin the photoresistor is connected to the photoresistor is not calibrated to any units so (relative light)
//Motor Pin
int motorPin = 9; //the pin is controling the DC motor use one of the PWM (pulse width modulation pins)
void setup()
{
pinMode(motorPin, OUTPUT); //sets the DC motor pin to output of the circuit
}
/*
* loop() - this function will start after setup
* finishes and then repeat
*/
void loop(){
int threshold = 300;
if(analogRead(lightPin) > threshold){
digitalWrite(motorPin, HIGH);
}else{
digitalWrite(motorPin, LOW);
}
}
After entering this code into the IDE be sure to upload it to your Arduino Board. You can do this by clicking the arrow in the green circle in the upper left hand corner of the IDE program.
Encasement
![IMG_0642.JPG](/proxy/?url=https://content.instructables.com/FIR/6789/ILZG47T2/FIR6789ILZG47T2.jpg&filename=IMG_0642.JPG)
![IMG_0643.JPG](/proxy/?url=https://content.instructables.com/F5H/J72J/ILZG47XT/F5HJ72JILZG47XT.jpg&filename=IMG_0643.JPG)
![IMG_0644.JPG](/proxy/?url=https://content.instructables.com/FJN/CYHE/ILZG47Y5/FJNCYHEILZG47Y5.jpg&filename=IMG_0644.JPG)
I am a little (pun intended) terrified of my Arduino and breadboard getting destroyed by one of these little green menaces especially after this trap tricks them into capture.
In this step, we will be enclosing our board into the plastic food container to conceal the electronics from grubby little hands of destruction.
You are want to find a form-fitting container. In the image above you can see this container is a snug fit which will allow protection for the board.
You will need to drill a hole in the lid of your container to expose the light sensor (photoresistor) as well as drill a hole in the side of your container to expose the DC motor and allow it to spin freely.
Decorate the Trap
![IMG_0637.JPG](/proxy/?url=https://content.instructables.com/FYU/5R1W/ILY0S7XI/FYU5R1WILY0S7XI.jpg&filename=IMG_0637.JPG)
![IMG_0638.JPG](/proxy/?url=https://content.instructables.com/FET/G7SZ/ILY0S7XK/FETG7SZILY0S7XK.jpg&filename=IMG_0638.JPG)
We now need to disguise this trap. In this phase of the process, you will be using your craft supplies to decorate the trap as you see enticing for a leprechaun. We used green construction paper to cover our box. In this phase, we also added stickers and other decorations to lure in the green guys.
Putting It All Together
![IMG_0642.JPG](/proxy/?url=https://content.instructables.com/F7E/78M3/ILZG4927/F7E78M3ILZG4927.jpg&filename=IMG_0642.JPG)
![IMG_0658.JPG](/proxy/?url=https://content.instructables.com/FZM/CZEA/ILZG499J/FZMCZEAILZG499J.jpg&filename=IMG_0658.JPG)
![IMG_0659.JPG](/proxy/?url=https://content.instructables.com/FD3/XURJ/ILZG48ZP/FD3XURJILZG48ZP.jpg&filename=IMG_0659.JPG)
![IMG_0643.JPG](/proxy/?url=https://content.instructables.com/F99/EFEI/ILZG492A/F99EFEIILZG492A.jpg&filename=IMG_0643.JPG)
![IMG_0645.JPG](/proxy/?url=https://content.instructables.com/FWV/QL7T/ILZG494O/FWVQL7TILZG494O.jpg&filename=IMG_0645.JPG)
![IMG_0646.JPG](/proxy/?url=https://content.instructables.com/F8M/C31M/ILZG4972/F8MC31MILZG4972.jpg&filename=IMG_0646.JPG)
Once we have our breadboard setup and organized, the Arduino coded, our trap decorated, and our encasement prepped we need to put everything together.
First, we will be putting the Arduino and breadboard into the food container and attach the 9v battery to the battery holder and then plug it into the Arduino. If you are working in a well-lit room your DC motor should start running as soon as you plug the battery and battery holder in. You may want to place a sticker, post-it note or tape on the sensor while you are assembling everything. Your container should allow for space to tuck your power source into the container. This keeps everything protected inside of the container.
Next, you will be adjusting the height of your Arduino and breadboard so your photoresistor sticks out of the hole your drilled. In the image above you can see I stacked sheets of paper, (cardboard could also be used). The photoresistor (light sensor) should be flexible enough to “wiggle” around until you get it to poke out of the drilled hole.
Now, we will be strategically placing our coin on top of the hole covering the photoresistor. (If you covered the photocell while you were assembling it remove that sticker now.)
We are now going to carefully set our container with the Arduino, breadboard and coin in place. In our project we set the container inside of our shoe box lid. This allowed our DC motor to hang out the side of the box and be elevated it enough to spin. The DC motor will need enough clearance to wind up the string or cord.
We are now attaching the string to our rod. We choose to use a set of magnetic rods as they would keep the lid of the box up with the structure we are looking for while still separating easily so that the lid can fall.
Set the Trap
![IMG_0660.JPG](/proxy/?url=https://content.instructables.com/F6Y/BGRG/ILZG4CJ8/F6YBGRGILZG4CJ8.jpg&filename=IMG_0660.JPG)
Finally, we prop our box lid up on top of our rod above our base and wait. We wait for the little green bothers to show up, overcome with greed as the grab as they snatch the coin. Then we as captors joyfully celebrate as the box shakes across the floor.