How Make Mouse Trap at your home
top of page

How Make Mouse Trap at your home


Circuit:


Arduino Programming:


#include <Servo.h>


int ir_sensor = A0;

Servo myservo;

int pos = 0;


void setup() {

  myservo.attach(9);

  myservo.write(0);

  

}


void loop() {

  int sensor_value = analogRead(ir_sensor); //read the sensor value

  int distance_cm = pow(3027.4/sensor_value, 1.2134); //convert readings to distance(cm)


  if (distance_cm < 10) {

  myservo.write(180);

  delay(10);

  }

  else

    delay(1000);

    myservo.write(0);

    delay(100);

}


  




Demo Video:


144 views0 comments

Recent Posts

See All
bottom of page