Feeding times may be made more dependable and effective by automating typical pet care tasks.
Using an Arduino Uno, an IC 7809 voltage regulator, a servo motor SG90, and an ultrasonic distance sensor HC-SR04, this project aims to create a basic automated pet feeding.
The intention is to construct a feeder that uses distance measures to deliver food, guaranteeing that pets eat at the appropriate time without the need for human assistance.
This circuit is great help to the owners which can save their time to feed their pets on regular interval.
Code with Explanation:
#include <Servo.h>
Servo myservo; // create a servo object to control the servo
const int trigPin = 9; // Trigger pin of the ultrasonic sensor
const int echoPin = 10; // Echo pin of the ultrasonic sensor
const int
servoPin = 2; // Servo motor pin
int duration, distance;
void setup() {
myservo.attach(servoPin); // attach the servo to pin 2
pinMode(trigPin, OUTPUT); // sets the trigPin as an output
pinMode(echoPin, INPUT); // sets the echoPin as an input
}
void loop() {
// Generate a pulse of 10us on the TRIGGER pin
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Read the duration of the pulse on the ECHO pin
duration = pulseIn(echoPin, HIGH);
// Calculate the distance in centimeters
distance = duration * 0.0343 / 2;
// Check if a pet is within the desired range
if (distance >= 10 && distance <= 20) {
// Dispense food by rotating the servo
myservo.write(90); // Adjust the angle as needed
delay(1000); // Delay for dispensing
myservo.write(0); // Return to initial position
}
// Add code for timer-based feeding if desired
}
Explanation:
- The Servo library, which offers functions for managing servo motors, is included in this line.
- A Servo object called myservo is created by this line.
- The servo motor will be controlled by this item.
- The trigger pin (trigPin), echo pin (echoPin) and servo pin (servoPin) of the servo motor and ultrasonic sensor, respectively, are defined by these lines as constant integer variables.
- The recorded ultrasonic pulse duration and the computed distance are stored in the integer variables duration and distance, respectively, which are declared in these lines.
- There is a single call to this function upon program startup.
- The myservo object is fastened to the designated servo pin (servoPin).
- It configures the echo pin (echoPin) as an input pin and the trigger pin (trigPin) as an output pin.
- This function is called repeatedly in a loop.
- The trigger pin (trigPin) creates a brief pulse in order to emit an ultrasonic sound wave.
- To determine the distance to the object, it measures the length of the echo pulse on the echo pin (echoPin).
- It verifies if the estimated distance is within a predefined range (10-20 cm in this example).
- It turns the servo motor to a precise angle (in this case, 90 degrees) to distribute food if the distance is within the range.
- If necessary, you can add code to enable timer-based feeding.
Circuit Working:
Parts List:
Component | Quantity |
---|---|
Arduino Uno | 1 |
IC 7809 (Voltage Regulator) | 1 |
Servo Motor SG90 | 1 |
Ultrasonic Distance Sensor HC-SR04 | 1 |
In the below circuit diagram you need to select a container that has enough room to accommodate your pets food.
To help direct the food into the dispensing mechanism, attach a open and close lid which is controlled by servo motor.
Install the servo motor in the enclosure so that it can regulate the food containers opening and shutting.
The ultrasonic sensor should be mounted such that it can identify pets within a given range.
Make sure the area where the pet is anticipated to approach is clearly visible to the sensor.
To shield the completed parts from the weather, place them within the enclosure.
Make a little aperture so the pet can get to the food.
To reduce a larger voltage such as 12V to 5V, which is needed by the Arduino, Servo motor, and HC-SR04 sensor, use the IC 7809 voltage regulator.
The sensor and servo are powered by the regulated 5V that is fed to the breadboard.
The HC-SR04 sensor gauges its distance from an item, such as a pet.
It generates ultrasonic waves and uses the time it takes for the waves to return to determine how far away anything is.
The dispensing mechanism is managed by the servo motor.
It may be used to open or close the feeder by rotating to a specified angle, which it gets instructions to do from the Arduino.
How to Build:
To build a mart Pet Feeder Circuit using Arduino following steps need to be followed for assembling:
- Gather all the components as mentioned in the above circuit diagram.
- Connect a regulated IC1 7809 to provide a regulated 9V DC to the Arduino board as per the above circuit diagram
- Connect Servo Motor SG90 black wire to GND on Arduino board, connect red wire to 5V on Arduino board and connect brown wire to pin 2 on Arduino board.
- Connect Ultrasonic Distance Sensor HC-SR04 VCC pin to 5V on Arduino board, connect TRIG pin of Ultrasonic Distance Sensor HC-SR04 to pin 9 on Arduino board, connect ECO pin of Ultrasonic Distance Sensor HC-SR04 to pin 10 on Arduino board and connect GND pin of Distance Sensor HC-SR04 to pin GND on Arduino board
Conclusion:
This simple circuit for an automatic pet feeder shows how to build a simple automated feeding system using an Arduino Uno, a servo motor, and an ultrasonic sensor.
Pet care may be made more easy by utilizing these components to guarantee that your pet is fed without the need for human interaction.
References:
Reliable Smart Pet Feeding Machine Using Arduino Uno Starter Kit
Leave a Reply