Learn electronics for beginners: How to make a DIY pet feeder with an Arduino board and a cardboard
Introduction
Hello there!! Welcome to another exciting episode of our Science class for kids.
This is Makersgeneration, and if you're a fan of anything STEM: this is the place to be!!
Have you ever been in a situation where you are out of the house let's say for a short trip and you kept wondering who will feed your pet when they are hungry while you are gone?? Worry no more, we're about to provide a solution to that. We will be making an automatic DIY pet feeder using just an Arduino and servomotor!! Cool right....?
This episode is as innovative as it can get, as we will not only be having fun but we'll also be solving a real-world problem while at it.
Workings
The main components for this project will be the Arduino board and servo motor. For the newcomers in the house, an Arduino is a small computer that you can program to control electronic devices like lights, motors, sensors, and more. It's like a brain for your DIY electronics projects. A Servomotor on the other hand is a type of DC motor with gears inside that you can control with the Arduino to move its hand in any direction.
In this project, the lid of the feed container is attached to the servo motor. The servo motor is programmed using the Arduino to open and dispense the feed at any desired time. This is done by moving the shaft of the servo to an angle, whereby moving the lid away from the opening of the feed holder and moving the lid back in place after the feed has been dispensed.
Let's take a look at the full list of components required to make our DIY pet feeder below:
Materials we'll need
Arduino Uno board
USB cable
1 Servo motor
3 Male-Male jumper wires
Cardboard paper
Knife or cutter
Plastic bottle
Glue
Bowl
Steps to make our DIY Arduino pet feeder
With our needed materials in place, let's dive right into making!!
Step 1:
Measure and cut out holes: the size of the bottle mouth and the servomotor on the cardboard paper.
Step 2:
Cut off the bottom part of the bottle. The bottle will serve as the container to hold the pet feed.
Step 3:
Fix the bottle and the servomotor in their respective holes on the cardboard with the servomotor arm facing the bottle and slightly higher than the bottle opening to give room for the lid. You can secure them in place with glue.
Step 4:
Cut a smaller piece of cardboard and attach it to the arm of the servomotor. This will act as the lid for the bottle.
Step 5: - Circuit
Connect the Brown wire of the servo motor to the GND pin on the Arduino board.
The Red wire of the servo motor to the 5V pin on the Arduino board.
Finally, connect the Yellow wire of the servo motor to the Pin9 on the Arduino board.
Step 6:
Place your setup on top of a bowl with the servomotor and the mouth of the bottle facing inside the bowl.
The complete setup should look like this:
Now that our physical setup and the circuit is complete, let's program the system.
Arduino Code for pet feeder
We are going to program our pet feeder to dispense feed every 5 seconds.
Launch your Arduino IDE and create a new sketch file, copy the code below and paste it there. Upload the code to your Arduino board.
#include <Servo.h> // call servo library
Servo myservo; // create servo object to control a servo
// time
unsigned long startTime = 0;
unsigned long seconds = 0;
unsigned long minutes = 0;
unsigned long hours = 0;
void setup() {
Serial.begin(9600); // initialize serial monitor
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
// count time
if (startTime == 0) {
startTime = millis();
}
unsigned long elapsedTime = millis() - startTime;
seconds = elapsedTime / 1000;
minutes = seconds / 60;
hours = minutes / 60;
seconds = seconds % 60;
minutes = minutes % 60;
hours = hours;
// control bottle lid after every 5 seconds then restart
if (seconds > 4){
// move servo to 40 degree position to open bottle lid
myservo.write(40);
delay(200); // waits 200ms
// move servo to 100 degree position to close bottle lid
myservo.write(100);
startTime = 0; // restart time
}
// print time on Serial monitor
Serial.print("seconds: ");
Serial.println(seconds);
Serial.println("");
delay(1000); //pause loop for 1 second
}
Code Explained
First, install the servo library. Next, the system is programmed to dispense feed after 5 seconds. The servomotor moves to angle 40 to move the lid away from the bottle opening for about 200 milliseconds to release the feed, then closes again by moving the arm of the servo to angle 100 sliding the lid back under the bottle opening. The loop continues until your feed container is empty.
You can always change the timing between dispensing by editing the number of seconds in the if statement(). You can even change the seconds to minutes or hours.
Check the demo video below.
Video demo
Wow!! If yours is working fine, congratulations!! You no longer have to worry about who will feed your pet whenever you are out of the house.
Okay... if the workings of this project got you as excited as I am, then you'll want to check other Engineering challenges for kids and other Easy STEM activities we have on this platform for you.
STEM Summer camp in DC and Maryland
You are looking for a nice 2024 summer camp for this year for your children focusing on STEM (Learn how to code, make robots, use 3D printing, droning, and more) in the Washington DC, Maryland, and Northern Virginia area. Come join us in Silver Spring Maryland where your children can learn and have fun.
Check the following link for more details and the dates:
Online after-school focused on STEM
You and your children are looking for nice activities to have fun and learn new things and skills. Come join us for online classes such as:
Python coding for kids and teens
Coding for elementary school students
Make video games
Electronics
Digital modeling (Create cars, rockets, rings, etc) for 3D printing and much more with the following link: Online after-schools
Other cute things to make and hand-crafts for kids (tutorials)
If you are looking for more cool Arduino and STEM project ideas to do with your kids, take a look at these other activities:
Newsletter, follow, subscribe, and like the social media
If you like online STEM activities, consider subscribing to the newsletter and social media for updates, and don't miss any STEM events. Don't forget to subscribe to the newsletter at the bottom of our website ''www.makersgeneration.net'' for more events, tutorials, and freebies.
Subscribe to the Facebook group if you have yet registered. Content and tutorials are shared daily: Create and build STEM projects for kids
We can be reached at: contact@makersgeneration.net if any questions.
See you very soon.