Arduino Mouse trap

This is the arduino mouse trap done by Nate Gendron and Jack Wright.

Basic Description:

Our mousetrap is basically a servo push button program except instead of a push button we are using a PIR sensor inside of a tupperware container held open by a wooden peg. PIR stands for pyroelectric infrared or simply motion detectors. These are extremely sensitive sensors. They can sense motion from up to twenty feet. Therefore, we had to take the lens off of the sensor, which extends its range. It was still very sensitive so we put a paper towel roll around the sensor to limit the width of sight. It was still sensitive so we cover the end of the tube with a cracker. When the mouse even nudges the cracker the sensor will react and pull the servo dropping the tupperware container shut.

Program Description:

Basically we used the push button to a servo program. However, we replaced the push button with the PIR sensor. The servo acts as a digital OUTPUT as a result of the digital INPUT taken from the sensor. If the value of the sensor is high (push button turned on) then the servo will go from 0 to 180 degrees. If the value is low (push button off, then the servo will not act.

Circuit Diagram:

Pictures:

Video:

Porgram:

int servoPin = 9;

int myAngle;

int pulseWidth;

int button = 2; //sets the button to pin2

int val = 0; //sets the value to 0

void setup ()

{

pinMode(servoPin, OUTPUT);

pinMode(button, INPUT); //sets the push button as an input

Serial.begin (9600); //sets serial to 9600 bits per second

}

void servoPulse(int servoPin, int myAngle)

{

pulseWidth = (myAngle * 10) + 600;

digitalWrite(servoPin, HIGH);

delayMicroseconds(pulseWidth);

digitalWrite(servoPin, LOW);

}

void loop()

{

val = digitalRead (button); //sets the value to the state of the button

if (val==HIGH){ //if the push button is pressed proceed with the for loop

for (myAngle = 0; myAngle <= 180; myAngle++)

{

val = digitalRead (button); //Reads the button between every angle change

if (val==LOW) //if the button is released, the angle goes back to 30

{

myAngle = 0;

}

servoPulse (servoPin, myAngle);

delay (10);

}

for (myAngle = 180; myAngle >=0; myAngle--) //If the button is not released, the loop returns to 30 and continues

{

servoPulse (servoPin, myAngle);

delay (10);

}

}

}

Problems Encountered:

Well first we used a laser trip wire. This was very simple, but we had a hard time getting it set at the right angle without the tupperware interfering, leaving room for the food, and making sure the mouse was underneath the tupperware so it wouldn't close if it wasn't even in the trap yet. Then we tried to use a program called gobetwino. This program basically lets you do the things that arduino cannot. It can start up any program on the computer. We wanted it to send an e-mail to Mr. Dickie if the trap was set off. Of course we didn't have the right software on our computer. Then, when we started using a PIR sensor. It can detect motion from up to twenty feet. So as you can imagine it was extremely sensitive. Everytime we plugged it in it was set off.

If we had more time/money:

We would really like to use all three types of sensors at once so if the mouse set any one of them off and catch the mouse. Also, the gobetwino was a great idea, but we needed different types of software and bug fixes.