October 2024
My cat prefers running water, so I made a small fountain. The water sits in a white plastic tower with a bowl at the bottom, and a little submersible pump moves it. An ultrasonic sensor watches the bowl, so the pump only runs when the cat comes to drink.
An Arduino UNO runs the pump through an OSOYOO Model-X motor driver, which is basically an L298N. The parts came to around $60.
Parts
- OSOYOO UNO board
- Model-X motor driver
- Mini water pump (3–5 V)
- HC-SR04 ultrasonic sensor
- ESP8266 WiFi shield
- Jumper wires
Code
I lost the original sketch, so this is a rewrite. When the sensor sees something closer than 30 cm, the pump starts slowly, and it keeps running until a minute after the cat leaves. The sensor's TRIG and ECHO go to pins 9 and 10. The driver's ENA, IN1 and IN2 go to pins 5, 7 and 8, with the jumper on ENA removed so the speed can be set.