Whether youâre working late or just want to sleep past 5 AM without your cat screaming at you, an automated pet feeder is one of the most practical projects you can build. In this project, weâre combining a Real-Time Clock with a heavy-duty Servo Motor to violently dump kibble into a bowl at the exact same time every day.

Our pet feeder relies on a simple mechanical action controlled by perfectly timed software:
For the electronics, youâll need the following components (links included to grab them on Amazon):
Youâll also need some cardboard, PVC pipe, or 3D-printed parts to build the physical food hopper!

VCC to Arduino 5VGND to Arduino GNDSDA to Arduino A4SCL to Arduino A5Brown Wire (Ground) to Arduino GNDRed Wire (Power) to Arduino 5V (or external 5V power source)Orange Wire (Signal) to Arduino Digital Pin 9This code uses the RTClib for the clock and the standard Servo library. Make sure you install RTClib by Adafruit via the Library Manager in the Arduino IDE.
#include <Wire.h>
#include <RTClib.h>
#include <Servo.h>
RTC_DS3231 rtc;
Servo feederServo;
const int servoPin = 9;
const int openAngle = 90; // Angle to open the dispenser
const int closedAngle = 0; // Angle to close the dispenser
// Set feeding times (24-hour format)
const int feedingHour1 = 8; // 8:00 AM
const int feedingMin1 = 0;
const int feedingHour2 = 18; // 6:00 PM
const int feedingMin2 = 30;
bool fedThisMinute = false;
void setup() {
Serial.begin(9600);
feederServo.attach(servoPin);
feederServo.write(closedAngle); // Ensure it starts closed
if (!rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
if (rtc.lostPower()) {
Serial.println("RTC lost power, let's set the time!");
// When time needs to be set on a new device, or after a power loss, the
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
}
void loop() {
DateTime now = rtc.now();
Serial.print("Current Time: ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.println(now.minute(), DEC);
// Check if it's time to feed
if ((now.hour() == feedingHour1 && now.minute() == feedingMin1) ||
(now.hour() == feedingHour2 && now.minute() == feedingMin2)) {
if (!fedThisMinute) {
Serial.println("Dispensing Food!");
dispenseFood();
fedThisMinute = true; // Prevent multiple feedings in the same minute
}
} else {
// Reset the flag once the minute passes
fedThisMinute = false;
}
delay(10000); // Check every 10 seconds
}
void dispenseFood() {
feederServo.write(openAngle);
delay(1000); // Keep open for 1 second (adjust based on portion size)
feederServo.write(closedAngle);
}
setup(), the Arduino connects to the RTC and attaches the servo. If the RTC lost power (e.g., the coin cell battery died), it automatically syncs with the time you compiled the sketch.loop(), it reads the current time from the RTC.dispenseFood(), turning the servo to 90 degrees to drop the food, then immediately returns to 0 degrees.fedThisMinute boolean ensures that it only dispenses once per minute, rather than dropping food continuously for 60 seconds!Once you get the electronics working, the real fun is designing the mechanical hopper. You can use an old cereal dispenser, a custom 3D printed auger, or a simple sliding trapdoor made from cardboard.
You could also add a push button for âmanual feedingâ outside of the schedule, or even a buzzer to play a sound to call your pet when dinner is served!