Arduino Fish Feeder

Maker from USA. Follow me to stay up to date on my projects and possible kickstarters! Business...

Intro: Arduino Fish Feeder

Do you have a fish at home? Are you like me, and you occasionally forget to feed your water loving pet? If so, this project is perfect for you. Its Simple, Cheap, and fun to make!

This project is great for students who leave ealy and may not have time to feed fish in the morning

Please vote for this project in the DIY University contest and the Age of aquariums contest

This is an really cool arduino project, that uses just two electronic parts. The arduino sketch is set up to feed the fish every 12 hours, but you can change it to whatever number you like. After building, all you need to do, is to clip your device onto your aquarium and forget about it! Thats all you do!

Lets start building!

Note: I started a YouTube channel to document my projects better, subscribe for more projects!

Difficulty: easy..

Cost (Not counting Arduino): easy..

Step 1: You Will Need...

For this project you will need

SUPPLIES

  1. Arduino
  2. Servo (any kind)
  3. Binder Clips
  4. An empty shampoo bottle
  5. Fish Food
  6. Jumper Wires
  7. Empty food takeout container (Clean or unused)

TOOLS

  1. Drill
  2. Hot Glue Gun
  3. Computer (to code)

Step 2: Shampoo Bottle

Using a empty shampoo bottle and your drill, drill a small hole on both sides of the shampoo bottle.

This is where the food will fall out, so you should test if food falls out by filling it up, and rotating it while holding it horizontally

DONT DRILL TOO BIG OF A HOLE!

Your fish will end up fat!

Drill a hole small enough so only 1-5 pellets fall out, depending on the size or number of fish you have

Step 3: Wiring and Programing!

Wire the ardunio according to the above picture.

Using jumper wires, follow this pattern

Connect Yellow or data to PIN 9

Connect Black to GND
Connect Red to +5V


Next use the code I have provided to upload to your arduino

Note: I'm not the best Programmer........ I'm still learning, If you see anything I can improve Please Tell Me!

// CONSTRUCTED'S Fish Feeder
// https://www.instructables.com/member/Constructed/
// Donate for more projects! 


#include  
 
Servo myservo;  // create servo object to control a servo 
                // a maximum of eight servo objects can be created 
 
int pos = 0;    // variable to store the servo position 

long FISHFEEDER = 43200000; // 12 hours between feeding
long endtime; 
long now;

void setup() 
{ 
 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
  
  myservo.write(0);
  delay(15);
  
}
 
void loop() 
{ 
  now = millis();
  endtime = now + FISHFEEDER;
  
  while(now < endtime) {
   myservo.write(0);
   delay(20000);
   now = millis();   
  }
  

  for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
}

Step 4: Prepare Case

First Cut a square just big enough to squish your servo through, It should be very tight!

next get your hot glue gun and glue both the binder clips to the back of your case.

Try to line them up as best as you can, They will clip to the back of your aquarium

Next take some hot glue and glue a servo horn to the bottom of your shampoo bottle. Put the servo horn back onto the servo and go to the next step

Step 5: Your Done!

Simply fit all the electronics into the case, and wedge the servo in last. Now clip your automatic fish feeder to any aquarium and your done!.

Have fun and now you don't need to worry about feeding your fish!

Please vote and favorite this intructable, I really appreciate it.

Thank you

Age of Aquariums Contest

Second Prize in the
Age of Aquariums Contest

Share

Recommendations

  • Optics Contest

    Optics Contest
  • Audio Contest 2018

    Audio Contest 2018
  • Plastics Contest

    Plastics Contest

34 Discussions

0
None
ElishebaW

2 years ago

Here's the correct code. I fixed it.

#include <Servo.h> // create servo object to control a servo

// a maximum of eight servo objects can be created

Servo myServo; // variable to store the servo position

long FISHFEEDER = 80; // 12 hours between feeding

long endtime;

long now;

void setup()

{

myServo.attach(9); // attaches the servo on pin 9 to the servo object

myServo.write(180);

delay(15);

}

void loop()

{

int position;

now = millis();

endtime = now + FISHFEEDER;

while(now < endtime)

{

myServo.write(0);

delay(20000);

now = millis();

}

for (position = 0; position < 180; position += 1) // goes from 0 degrees to 180 degrees

{ // in steps of 1 degree

myServo.write(position); // tell servo to go to position in variable 'pos'

delay(15); // waits 15ms for the servo to reach the position

}

for (position = 180; position>=1; position-=1 ) // goes from 180 degrees to 0 degrees

{

myServo.write(position); // tell servo to go to position in variable 'pos'

delay(15); // waits 15ms for the servo to reach the position

}

}

2 replies
0
None
bhairavis1ElishebaW

Reply 10 days ago

Hello mam, I have done my project using your code. Can you please guide me for how can I implement bluetooth module in this project?

0
None
RobC81ElishebaW

Reply 2 years ago

hi will this code move the servo 0-180 degrees and back again , once in 12 hours ? or the code thats in the instructable ?

0
None
ErnestoE15

Question 4 months ago on Step 2

how do I do it to be able to make the food ciga every 6 hours?

and what voltage is used?

0
None
DenisZ4

2 years ago

I am using SimpleTimer library for setting up time interval between feedings.

In addition I turn off the Servo Motor between feedings so that it doesn't make any noise and also doesn't drain the battery.

Hope someone can find this code useful.

#include <Servo.h> // create servo object to control a servo

#include <SimpleTimer.h>

Servo myservo; // create servo object to control a servo

// the timer object

SimpleTimer timer;

int pos = 0; // variable to store the servo position

void setup() {

myservo.write(0);

Serial.begin(9600);

timer.setInterval(86400000, feedMyFish); // Feed every 24 Hours

}

void feedMyFish() {

myservo.attach(9);

for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees

// in steps of 1 degree

myservo.write(pos); // tell servo to go to position in variable 'pos'

delay(15); // waits 15ms for the servo to reach the position

}

for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees

myservo.write(pos); // tell servo to go to position in variable 'pos'

delay(15); // waits 15ms for the servo to reach the position

if (pos == 0) {

myservo.detach(); // Turn off Servo motor between feedings

}

}

}

void loop() {

timer.run();

}

3 replies
0
None
DeanTheCreatorDenisZ4

Reply 11 months ago

Please note that you need to download the simple timer library and put it into your Documents\ArduinoData\staging\libraries folder.

0
None
ArminE6

7 months ago

Hi,
I have a problem with arduino, when I upload the code to the Arduino, no matter the value of "FISHFEEDER" variable is, when i plugg the arduino with USB, the servo starts to spining without stop!!!!!! it keeps working all the time!!

what is the problem? what did i do wrong?

tools i am using:

Arduino Uno R3

Micro Servo 9g (Tower Pro - SG90)

0
None
ArminE6

Question 7 months ago on Step 3

Hi,
I have a problem with arduino, when I upload the code to the Arduino, no matter the value of "FISHFEEDER" variable is, when i plugg the arduino with USB, the servo starts to spining without stop!!!!!! it keeps working all the time!!

what is the problem? what did i do wrong?

tools i am using:

Arduino Uno R3

Micro Servo 9g (Tower Pro - SG90)

0
None
DeanTheCreator

11 months ago

When I turned it on the timer went off every 11 hours not 12 (first a 7pm then 6am then 5pm). Do you know why?

0
None
viakaren

2 years ago

Hey.. where did you do the coding? Im sorry i really have no idea in using arduino but now our professor want us to develop a system using arduino. I just dont know how it works, how to connect the code so the goal will be achieve..

3 replies
0
None
Constructedviakaren

Reply 2 years ago

to be honest I never learned arduino. I make it up as I go using bits and pieces of other code I know.

0
None
ElishebaWviakaren

Reply 2 years ago

You just kinda pick it up from starter kits and peoples projects online. It's based off C++ tho.

0
None
sanket_22

1 year ago

hie, i want a program to rotate the servo motor using push button ie switch so can anyone help me with the main loop code

1 reply
0
None
DeanTheCreatorsanket_22

Reply 11 months ago

I'm not too good at code but this code should allow you to turn the servo with just one press...

#include <Servo.h> // create servo object to control a servo

Servo myservo; // create servo object to control a servo

int buttonPin = 7; // choose the input pin (for a pushbutton)

int buttonVal = 0; // variable for reading the buttons pin status

int pos = 0; // variable to store the servo position

void setup() {

pinMode(buttonPin, INPUT);

myservo.write(0);

Serial.begin(9600);

}

void feedMyFish() {

myservo.attach(9);

for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees

// in steps of 1 degree

myservo.write(pos); // tell servo to go to position in variable 'pos'

delay(15); // waits 15ms for the servo to reach the position

}

for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees

myservo.write(pos); // tell servo to go to position in variable 'pos'

delay(15); // waits 15ms for the servo to reach the position

if (pos == 0) {

myservo.detach(); // Turn off Servo motor between feedings

}

}

}

void loop() {

buttonVal = digitalRead(buttonPin); // read button input value

if (buttonVal == HIGH) { // check if the input is HIGH (button released)

//do nothing

} else {

feedMyFish();

}

}

0
None
RCM19

1 year ago

​Hi. I'm currently creating this Fish Feeder but I have a problem. If you know the solution, please help me, I need the solution fast for a project.
When I enter the code it tells me: The Sketch uses 2,314 bytes (7%) of the program storage space. The maximum is 32,256 bytes. The Global variables use 62 bytes (3%) of the dynamic memory, leaving 1,986 bytes for the local variables. The maximum is 2,048 bytes.
How can I solve that? Is it a problem of my Arduino or Servo? Please help. :)

0
None
aru2002

1 year ago

Thanks for the code.

I would like to add the code to enable transistor which supplies power to the motor before motor start code runs, then turn it after motor stops.

set pin 7 high - run motor code - set pin 7 low.

0
None
AdvaitJ2

2 years ago

I want to use the same arduino code for my other project which involves Dc motor in it please guide me to write the arduino code for it at intervals of 6hrs each