Introduction: Arduino Mouse Trap

Picture of Arduino Mouse Trap

Hi people!
For this Challenge, I created an Arduino controlled Mouse Trap to capture any unwanted pests that may wander into your space. The project is complete but I have one more addition that I will try to make. More about this at the end.

Step 1: Make the Box for the Trap

Picture of Make the Box for the Trap

Here is the basic trap box. The wire mesh was cut and bent to the shape. Size is 3" x 3" x 6" [7.5cm x 7.5cm x 15cm] long . The mesh is McMaster-Carr #9219T173. You get a 12" square piece. I cut out the piece as shown with a Dremel. Here is the pattern that I used.


Step 2: Make the Door and Hinge

Picture of Make the Door and Hinge

The door is a piece of polycarb that I had in my scrap box. It is 1/8" x 2" x 2". The hinge is a 1/8 dia. x 1-3/4 lg. tube that is glued to the Door top edge. The Hinge Pin is just a rod that fits inside the Hinge Tube. The Hinge Pin is glued to the TrapBox so that it is free to open and close.

Step 3: Servo Mount and Tie Rod

Picture of Servo Mount and Tie Rod

Servo support and IR sensor holders were also recycled from other previous projects. You
can make one from plastic or wood. The Servo support is a piece of phenolic. The Servo is just a Micro-Servo available from almost any electronics ebay vendor. Same with the IR Led and IR receiver. I bought them years ago, probably from Digi-Key. Again any ebay electronics vendor has them. Just get a pair matched to the same IR wavelength for best results.

At the bottom of the Door, I glued a short piece of tubing to fasten the Tie Rod from the Servo to. A wire was bent to go between the Servo Horn and the tube. You will have to adjust the Servo open and closed position in the sketch to get the Door open and closed correctly.

Step 4: Fritzing Schematic, Sequence of Operation & Code

Picture of Fritzing Schematic, Sequence of Operation & Code

Electrical/Electronic Parts List:

* Arduino UNO w/USB cable

* Micro Servo

* Breadboard

* LCD Display 20 x 4 Lines w/I2C backpack (4-wire connection to Arduino)

* IR Transmitter and Receiver Set

* 1k-1/2 watt Resistor

* 10k-1/2 watt Resistor

* 4.5v Battery Holder for Servo power

* 9vdc Battery for Arduino, LCD and Sensors

* Jumper Wires

Mouse Trap Operation Sequence.

1. Arduino is plugged into a 9v battery starting the sketch.

2. Servo moves to the start position which opens the door.

3. The Arduino checks for Door Opening and IR Sensor alignment

4. The condition of these checks appears on the LCD display.

5. Now the Arduino waits for a mouse to enter the Trap.

6. When a mouse enters, it should move towards the bait at the far end.

7. Just before the bait is a IR Transmitter and Receiver to act as a break-beam.

8. Breaking this IR beam activates the Servo to close the door.

9. Now your pest is trapped.

Step 5: Videos

Here are (3) videos of my Arduino Mouse Trap. As you can see in the videos, I had to use a toy mouse to demo the Trap. A live one was not available. All together I had about 3 hours in building this project. It was fun and I will update the project eventually. I have on order a ESP8266 board. I may be able to send a message to yur phone when the Trap is closed and a mouse caught.

I hope you enjoyed looking at my Instructable.


joshboye (author)2017-05-09

Cool project, I hope you modify it with the ESP8266 board.

Zohaib22 (author)2016-12-07

Any programming used??? Plz tell me i want it to present in my school.

-Gary (author)Zohaib222016-12-07

The code is available for download in Step #4 by clicking the "Mouse_Trap.ino" button.

Abby Aron (author)-Gary2017-02-10

I can't find it

-Gary (author)Abby Aron2017-02-10

It is in Step #4, below #9 of the Mouse Trap Operation Sequence.

奕軒呂 (author)2017-02-06

Does the Arduino program have the annotation?

saadi_420 (author)2016-07-21

I believe that the circuit is a little wrong??? the servo motor should be connected to pin 9 in the diagram?? not A0. !! right

-Gary (author)saadi_4202016-07-22

Good catch saadi_420! Thanks, it is now fixed.

-Gary (author)2016-06-10

Hi JhonattanX
To answer your question... the 1k resistor goes to the IR LED emitter, the 10k resistor goes to the IR transistor or receiver.
Sorry that I did not label it in my Fritzing schematic.


AdamR98 made it! (author)2016-04-10

Thanks gray for this tutorial.

very help me to finish my project school, i replace LCD with Bluetooh.

i show you in the last video, i force open the door, i think mouse can escape with this. are you Trap's door same like me?

teletobi (author)2016-04-03

Very nice one! But what are you doing if you caught one? The Trap in your Pictures is missing a Floor, you can´t lift it off the Floor with a Mouse inside. And maybe you will need an Escape Exit to let the Mouse out.

-Gary (author)teletobi2016-04-03

Hi teletobi

Very observant of you about not seeing a floor! The floor is included with the Box Trap.pdf template. I doubted if I would ever have to use the trap so I did not include the floor. The actuator wire pulls out from the door to open it. You would decide what to do with him. Maybe take him down the street and release him or whatever.

albatools (author)2016-03-21

where are the sensors connected to?

-Gary (author)albatools2016-03-21

One is an IR led, the other is an IR receiver. When a mouse breaks the IR beam, the Arduino reads it and closes the door.

gogoguy (author)2016-03-20

I love it! A humane trap. Plus, it beats cleaning up dead ones. GO Gary!

-Gary (author)gogoguy2016-03-20

Hey Thanks GoGoGuy!

Glad you liked my entry. I made this so if you felt sorry for the mouse, even though it is a pest, you could release him away from your house. Thanks for looking!


Lulux3 (author)2016-03-18

Its amazing! Can you please provide us with the arduino code , because i would like to try it for my school project

-Gary (author)Lulux32016-03-18

Hi Lulux3!

The code is included with this Instructable. Go to Step 4. Scroll down to just above the "NEXT >>" button and click on the icon Mouse_Trap.ino The code will download to you. Hope you get the project finished for your school.

thefrenchmaker (author)2016-03-15

Nice and fun project !

-Gary (author)thefrenchmaker2016-03-16

Hi x4nd3r!

Thanks for looking at my project entry. It is easy to build also. I forgot to mention it in the write-up but the Arduino checks to see if the IR sensors are aligned and reports the condition on the LCD display. This just helps to make sure the trap is ready to work correctly.

AhmedE41 (author)2016-03-07

now add some notification ;) email , sms , or buzz :D

-Gary (author)AhmedE412016-03-07

Hi AhmedE41,

I mentioned this a bit on the last Step. I have an ESP8266 project board on order. May arrive this week. I will update my project when I can get something working.

Thanks for looking at my entry!

PaulLowman (author)2016-03-06

Is the servo fast enough to trap a mouse?

-Gary (author)PaulLowman2016-03-07

Hey Paul, That is my first test when I get a live mouse to try. I can
make the door close faster by moving the tie-rod tube closer to the
hinge and shortening it. I am counting on the mouse to be more
interested in the bait than watching behind him. I have used a peanut
butter and bacon grease bait before with good results.

Thanks for looking at my entry..

diy_bloke (author)2016-03-05

A mousetrap with an LCD. Cool!!!! Not because it is necessary, but because you CAN!

-Gary (author)diy_bloke2016-03-05

Thanks diy_bloke! I appreciate your comment. I am a big fan of the LCD's. Try to include them in all my stuff.


diy_bloke (author)-Gary2016-03-06

with their prices, especially with I2C you'd be a fool not to :-)

rhysun (author)2016-03-04


Do this with an ATtiny85, loose the LCD (although I must admit it is cool), and make use of the '85's sleep mode and this thing will run for months on a single battery shift.

-Gary (author)rhysun2016-03-05

Thanks rhysun! The UNO for this project was maximum overkill. I had a tiny AdaFruit Trinket that I was going to use but opted for one of my Project Boards instead. The LCD was already attached so I thought, what the heck... I will use it. A little more of something to look at.

diy_bloke (author)rhysun2016-03-05

I agree, but I have tp admit, the LCD is cool and after all, can also do it with an opamp, or just a piece of wood and a spring.

nevertheless in a more general sense you are very right, many arduino projects that use a few pins can be done with an attiny in sleep mode and make it battery run

About This Instructable




More by -Gary:Arduino Mouse Trap
Add instructable to: