Automated mouse trap with ardiuno

 In this project I tried to build a plexiglas box with laser cut. I have used arduino, servo motor to release the door and ultrasonic sensor to detect the mouse inside the box.

If I had to it again, I would choose stronger servo motor, this specific one, was making some kind of noise, probably its because it was not strong enough to hold the door stretched with elastic.

After a while the servo turned itself without detecting anything. I am thinking that might be either the servo motor is weak or the plexiglas was reflecting to the sensor thereby creating the signal to servo.

Overall, I am very happy with the result and i really enjoyed it!

if you have a laser cutter at home or in a workshop where you can access to a laser cutter, you can contact me via the contact form on the right navigation bar so I can send you the project file by email.



Items used on the project.

1. Arduino Uno
2. Ultrasonic sensors
3. Servo motor
4. Drawing


Wirering diagram



Arduino Code:

#include <Servo.h>
Servo servo;
int const trig = 3;
int const echo = 2;

void setup()
{
pinMode(trig, OUTPUT); 
pinMode(echo, INPUT);
servo.attach(4);
}

void loop()
{       
  int duration, distance;
  digitalWrite(trig, HIGH); 
  delay(1);
  digitalWrite(trig, LOW);
  duration = pulseIn(echo, HIGH);
  distance = (duration/2) / 29.1;
  
  if (distance <= 8 && distance >= 0)
    {
    servo.write(50);
    delay(3000);
    }
    else {
      servo.write(160);
      }
      delay(30);
      }


                              


The links above are affiliate links, which means that if you choose to make a purchase, I will earn a commission. This commission comes at no additional cost to you. I recommend these items because they are fun to play with, especially if you are passionate about woodwork; not because of the small commissions I make if you decide to buy something.

No comments:

Post a Comment