Puppy Poop Alert: Arduino and distance sensor

The puppy poop alert is made to let me know when my dog Mia has to go potty. She often sits by the door and waits to go to the bathroom, but I am caught up on my computer or in the other room and I don’t notice.  There is a distance sensor that goes off when she goes to the door and asks to go out.  She will often sit there for an hour without me noticing! Eventually, if I’m not paying attention she will go pee on the rug 🙁 To avoid this, I made the puppy poop alert system.

I laser-cut the box to have paws that allow light and sound to go through. I made the sensor go off at less than 30 cm and placed it in near where she usually stands or sits.  The piezo buzzer sounds and a loud alarm and LED lights flash in the paws that I cut out of the side of the box.  I can now see and hear when she has to go to the bathroom, even when I am distracted!

In the future, I would like to add an LED to each paw cutout so they light up universally and maybe have the alarm play a short melody.  I plan to solder the wires and use it permanently!


Here is the code:

#define trigPin 7
#define echoPin 6
#define led 13
#define led2 12
int sound = 250;


void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(led, OUTPUT);
pinMode(buzzer, OUTPUT);


void loop() {
long duration, distance;
digitalWrite(trigPin, LOW);
digitalWrite(trigPin, HIGH);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;

if (distance <= 80) {
digitalWrite(led, HIGH);
sound = 600;
delay (10);
digitalWrite(led2, HIGH);
sound = 600;
delay (10);
digitalWrite(buzzer, HIGH);

else {

if (distance > 30 || distance <= 0){
Serial.println(“Out of range”);
else {
Serial.println(” cm”);
tone(buzzer, sound);


Site Footer