Build a cat litter box fan with Arduino

A hideaway cat litter box is a great way to make your apartment look like a residence for adults instead of crazy cat ladies. A hidden litter box in a cabinet, under a sink, or built in to some other furniture does a lot for appearances, but what about the smell? Here’s how you can exploit the power of baking soda and embedded computers to keep your apartment fresh-smelling without disturbing your cat during his or her “quiet time.”

Build a cat litter box fan with Arduino

What you’ll need:
An Arduino-compatible embedded microcontroller (I used the Kameduino and Chibiduino from Brown Dog Gadgets: and the Arduino IDE from
A 6-12 volt wall wart, or a 9 volt battery
A DC case fan, 80mm or so, 5-12 volts
A TIP120 “Darlington” NPN transistor (available at your local components drawer)
Three resistors – 220 ohm and two 1000 ohm
A “matched set” of an IR emitter and IR phototransistor (I got mine from Sparkfun:
A box of baking soda, ideally the “fridge and freezer” kind with the ventilation panels on the side
Some “poster tack” sticky mounting putty
Some rubber bands

You’ll need a soldering iron and some solder. A solderless breadboard is a great tool for prototyping circuits without making permanent connections. Let’s get started.

Step 1: Prototype the Circuit

The theory of operation is simple – when your cat enters his or her litter box hideaway, he’ll trip a simple breakbeam sensor and a timer will start, giving your cat enough time to do his “business.” After the timer counts down three minutes, a fan will start and run for another three minutes, pushing air through the ventilated sides of the baking soda box and trapping les mal odeurs.

It helps to breadboard the circuit, first. A Fritzing mockup of the circuit is provided.  If you bought your IR emitter and phototransistor from Sparkfun, then it may not be obvious which is which; try plugging them into 5 volt DC power (from your Arduino, perhaps) in series with the 1k resistor and viewing them through a digital camera (such as your cell phone.) While IR is invisible to the unaided human eye, digital cameras can see it quite handily particularly if they are poorly filtered (as most are.) The IR LED is the one that lights up with a purple color. The phototransistor will not light up at all. Remember that an LED works only in one direction; with the anode connected to power and the cathode to ground. Typically, the long lead is the anode.

In this setup, three pins of the Arduino are used. Pin 3 provides power to the LED. Pin 2, as an input, detectes the presence or absence of the IR beam. Pin 5 supplies current to the “base” of the TIP120, which allows current to flow from the “collector” to the “emitter” and activating the fan’s motor. Resistors in series with the LED and TIP120 prevent too much current from flowing through the delicate microprocessor. The resistor and the phototransistor form a voltage divider which will input to the Arduino in the presence of IR light.

Step 2: Program the Microcontroller

The Arduino team has made it easy to program your microcontroller from the Arduino IDE, which you’ll need to download and install. Once you have, create a new “sketch” and copy the code from below, or download the CatTimer.ino Arduino sketch:

#define SENSE_PIN 2
#define PULSE_PIN 3
#define FAN_PIN 5
#define FAN_DELAY 180000
#define FAN_RUN_TIME 180000

volatile boolean detectState;

void setup() {
pinMode(13, OUTPUT);
digitalWrite(SENSE_PIN, LOW);

void loop() {



For more detail: Build a cat litter box fan with Arduino

Clip to Evernote

Leave a Comment

(Spamcheck Enabled)

Read previous post:
A Simple Bat Detector based shield for the Arduino Uno

I've built a number of projects that have interfaced the output of the Simple Bat Detector with a microprocessor. The...

Scroll to top