Automatic Cat Door (prototype)





Introduction: Automatic Cat Door (prototype)

I live with a bunch of cats and they're allowed to go outside through a cat door. However, they like to go outside a lot which not only gets the cat door dirty easily, but it also makes a lot of sound when they go through. I decided I could try and make an automatic cat door prototype to solve both these problems and prevent me from waking up in the night!

Step 1: Preparing to Build the Prototype

You'll need a selection of items for this project. Here's what I used:

  • Arduino UNO
  • Micro servo motor
  • Breadboard
  • 10 wires
  • Ultrasonic sensor (HC-SR04)


  • 3 LEDs to display the current status of the cat door (maybe the cat could learn and understand these)
  • 3 resistors (10k ohm / 5% tolerance)

Step 2: Setting Up the Breadboard Wiring

Let's connect everything up first. We will start with the wiring for the power, ground and LEDs.

Step 3: Adding Resistors and LEDs on the Board

Next up we will add the resistors and LEDs to the board.

Step 4: Preparing the Ultrasonic Sensor

Add wiring for the ultrasonic sensor and connect the sensor to the board.

Step 5: Add the Servo Motor to the Board

Lastly we'll add the servo motor to the board. All that's left to do is code and finalize the cat door system!

Step 6: Building the Code

To make the cat door detect things, display the status and rotate the servo we need to build some code!

#define ledRed 2
#define ledYellow 3
#define ledGreen 4
#define pinEcho 12
#define pinTrig 13
const int MAX_DISTANCE = 10;
Servo servo;
bool isOpen;
bool isOpening;
void setup() 
    pinMode(ledRed, OUTPUT);
    pinMode(ledYellow, OUTPUT);
    pinMode(ledGreen, OUTPUT);
    pinMode(pinTrig, OUTPUT);
    pinMode(pinEcho, INPUT);
    isOpen = false;
    isOpening = false;
void loop() 
    if (getDistance() <= MAX_DISTANCE)
        digitalWrite(ledGreen, LOW);
        digitalWrite(ledYellow, HIGH);
        digitalWrite(ledRed, LOW);
        Serial.println("Checking if someone stays here.");
        if (getDistance() <= MAX_DISTANCE)
            digitalWrite(ledGreen, HIGH);
            digitalWrite(ledYellow, LOW);
            digitalWrite(ledRed, LOW);
            Serial.println("Someone still here... Checking if gate is open...");
            if (!isOpen)
                Serial.println("Gate is closed. Opening gate.");
                Serial.println("Opened gate.");
                isOpen = true;
                Serial.println("Gate is still open. Waiting for someone to leave.");
            Serial.println("Someone has left. Ignoring.");
        digitalWrite(ledGreen, LOW);
        digitalWrite(ledYellow, LOW);
        digitalWrite(ledRed, HIGH);
        // Serial.println("No one here. Attempting to close gate.");
        if (isOpen)
            Serial.println("Gate is opened. Closing gate.");
            Serial.println("Gate is closed.");
            isOpen = false;
int getDistance()
    long duration;
    int distance;
    digitalWrite(pinTrig, LOW);
    digitalWrite(pinTrig, HIGH);
    digitalWrite(pinTrig, LOW);
    duration = pulseIn(pinEcho, HIGH);
    distance = duration * 0.034 / 2;
    return distance;

Upload it to your Arduino and test it out!

Step 7: Optional: Finishing Up Your Project

Now that you're set with the basic structure of the project you're free to apply it to any cat door or create your own! I created my prototype with some cardboard to see if this would work (which it indeed does!).

Thank you for viewing this Instructable. If you have any cats, make sure to try it out!



    • Casting Contest

      Casting Contest
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Make it Move Contest

      Make it Move Contest

    We have a be nice policy.
    Please be positive and constructive.



    could you be more specific with the "10 wires" needed? what gauge, colors, length ...whatever else you can think of. thanx.


    That's neat :) What do you plan to build the final project with?