Create an Innovative and Reliable Arduino Automatic Pet Feeder

Are you concerned about feeding your pet when you’re away from home? This DIY Arduino Automatic Pet Feeder is the perfect solution for pet owners who want to ensure their pets are fed on schedule. In this project, you’ll learn how to build a programmable Arduino Automatic Pet Feeder that dispenses food at specified times using an Arduino, a servo motor, and a few other components.

Benefits of Using an Arduino Automatic Pet Feeder

Automating your pet’s feeding schedule with an Arduino Automatic Pet Feeder has several advantages:

  • Consistency: Ensures your pet gets fed at the same time every day.
  • Convenience: Eliminates the need for manual feeding, especially when you’re away from home.
  • Customization: Easily adjustable feeding times to suit your pet’s needs.

Project Overview

In this project, an Arduino Automatic Pet Feeder uses an Arduino Uno to manage a servo motor that controls a food dispenser. A 4×4 matrix keypad enables you to set feeding times, and a 16×2 I2C LCD displays the current time and date. The DS3231 RTC module ensures accurate timekeeping, even when the Arduino is turned off.

Key Features:

  • Set feeding times using a 4×4 matrix keypad
  • Display current time and date on a 16×2 I2C LCD
  • Automatic food dispensing at programmed times
  • Easy-to-use interface for setting and adjusting feeding schedules

Components Needed for the Arduino Automatic Pet Feeder

To build your Arduino Automatic Pet Feeder, you’ll need the following components:

  1. Arduino Uno: The core of your Arduino Automatic Pet Feeder project.
    Buy on Amazon
  2. 4×4 Matrix Keypad: For setting feeding times on your Arduino Automatic Pet Feeder.
    Buy on Amazon
  3. 16×2 I2C LCD: Displays the current time and date, as well as input feedback.
    Buy on Amazon
  4. DS3231 RTC Module: Keeps accurate time for your Arduino Automatic Pet Feeder.
    Buy on Amazon
  5. Servo Motor: Controls the food dispenser mechanism.
    Buy on Amazon
  6. Push Button: Used to set feeding times.
    Buy on Amazon
  7. Connecting Wires: For making electrical connections between components.
    Buy on Amazon
  8. Breadboard: For assembling your Arduino Automatic Pet Feeder.
    Buy on Amazon

Circuit Diagram of Arduino Automatic Pet Feeder

Step-by-Step Guide for Your Arduino Automatic Pet Feeder

Step 1: Install Required Libraries

Before starting with the code for your Arduino Automatic Pet Feeder, you need to install the required libraries. These libraries add functionality to your project, such as controlling the LCD display and reading time from the RTC module.

  1. Open the Arduino IDE.
  2. Go to Sketch > Include Library > Manage Libraries.
  3. Search for and install the following libraries:
    • LiquidCrystal I2C: For controlling the I2C LCD display.
    • DS3231: For interfacing with the DS3231 RTC module.
    • Keypad: For reading input from the 4×4 matrix keypad.

Step 2: Assemble the Hardware for Your Arduino Automatic Pet Feeder

Follow these steps to set up the hardware for your Arduino Automatic Pet Feeder:

  1. Connect the Servo Motor:
    • Attach the servo motor’s signal wire to pin 10 on the Arduino.
  2. Set Up the Keypad:
    • Connect the 4×4 keypad’s rows and columns to pins 2 through 9 on the Arduino.
  3. Connect the LCD:
    • Connect the 16×2 I2C LCD to the Arduino using the I2C interface (SDA to A4, SCL to A5).
  4. Connect the RTC Module:
    • Connect the DS3231 RTC module to the I2C interface.
  5. Add the Push Button:
    • Connect the push button to pin A3 on the Arduino.

Step 3: Upload the Code for the Arduino Automatic Pet Feeder

Here’s the complete code for your Arduino Automatic Pet Feeder. Copy the following code into the Arduino IDE and upload it to your Arduino Uno.

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <DS3231.h>
#include <Servo.h>
#include <Keypad.h>

const byte ROWS = 4; // Four rows
const byte COLS = 4; // Three columns

// Define the Keymap
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};

// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 2, 3, 4, 5 };

// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 6, 7, 8, 9 };

// Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

DS3231 rtc(A4, A5);
Servo servo_test; // Initialize a servo object for the connected servo
LiquidCrystal_I2C lcd(0x27, 16, 2); // Creates an LC object. Parameters: (rs, enable, d4, d5, d6, d7)

// int angle = 0;    
// int potentio = A0; // Initialize the A0 analog pin for potentiometer
int t1, t2, t3, t4, t5, t6;

boolean feed = true; // Condition for alarm
char key;
int r[6];
int btn = 12;

void setup() 
{ 
  servo_test.attach(10); // Attach the signal pin of servo to pin 9 of Arduino
  rtc.begin();
  // rtc.setTime(10, 44, 0); // Set the time 
  // rtc.setDate(18, 8, 2022); // Set the date 

  lcd.init();
  lcd.backlight();
  lcd.clear();

  servo_test.write(0); 

  Serial.begin(9600);

  pinMode(A0, OUTPUT);
  pinMode(A1, OUTPUT);
  pinMode(A2, OUTPUT);
  pinMode(A3, INPUT_PULLUP);
}

void loop() 
{ 
  lcd.setCursor(0,0);
  int buttonPress;
  buttonPress = digitalRead(A3);

  if (buttonPress == 0)
    setFeedingTime();

  lcd.print("Time: ");
  String t = "";
  t = rtc.getTimeStr(); 
  t1 = t.charAt(0) - 48;
  t2 = t.charAt(1) - 48;
  t3 = t.charAt(3) - 48;
  t4 = t.charAt(4) - 48;
  t5 = t.charAt(6) - 48;
  t6 = t.charAt(7) - 48;

  lcd.print(rtc.getTimeStr());
  lcd.setCursor(0,1);
  lcd.print("Date: ");
  lcd.print(rtc.getDateStr());

  if (t1 == r[0] && t2 == r[1] && t3 == r[2] && t4 == r[3] && t5 < 1 && t6 < 3 && feed == true)
  { 
    servo_test.write(100); // Command to rotate the servo to the specified angle 
    delay(1000);   
    servo_test.write(0); 
    feed = false;
  }
}

void setFeedingTime()
{
  feed = true;
  int i = 0;

  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Set feeding Time"); // LCD
  lcd.clear();
  lcd.print("HH:MM"); // LCD
  lcd.setCursor(0,1);

  while(1) {
    key = kpd.getKey();
    char j;

    if (key != NO_KEY) {
      lcd.setCursor(j,1);
      lcd.print(key); // LCD

      r[i] = key - 48;
      i++;
      j++;

      if (j == 2) {
        lcd.print(":"); j++; // LCD
      }
      delay(500);
    }

    if (key == 'D') {
      key = 0; break;
    }
  }
}

Step 3: Set the Feeding Time

  • Use the Keypad: Press the keys to set the hour and minute of the feeding times for your Arduino Automatic Pet Feeder.
  • Save the Time: Press the ‘D’ key to save the feeding time.

Step 4: Test Your Pet Feeder

  • Check the LCD Display: Ensure the current time and date are displayed correctly.
  • Observe the Servo Motor: At the programmed time, the servo motor should rotate to release food.

Additional Tips and Enhancements

  • Power Supply: Ensure you have a reliable power source for your Arduino and servo motor.
  • Modify Feeding Schedule: Adjust the feeding schedule as needed to accommodate your pet’s diet.
  • Add a Buzzer: Integrate a buzzer to alert when feeding is about to occur.

Frequently Asked Questions

How does an Arduino Automatic Pet Feeder work?
An Arduino Automatic Pet Feeder automates the feeding process by using a servo motor to control a dispensing mechanism. The Arduino board, programmed with specific feeding times, signals the motor to release a set amount of food when it reaches the programmed time.

Can I customize the feeding schedule?
Yes, the feeding schedule can be easily customized by using the keypad to input different times. You can set the feeder to dispense food at multiple times throughout the day, depending on your pet’s needs.

Conclusion

Building an Arduino Automatic Pet Feeder is a fulfilling project that guarantees your pet receives consistent meals. With just a few components and some programming, you can automate your pet’s feeding schedule, offering both convenience and peace of mind.

Explore More

If you enjoyed building the Arduino Automatic Pet Feeder, explore more Arduino projects on our website. Join our community to discover new DIY ideas and tutorials.

Latest Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Facebook
YouTube
× Contact us