Automatic Fish feeder using Arduino

Hello everyone, Welcome to my blog. Today we are going to make an Automatic fish feeder using Arduino. Suppose you are a lazy person or you are going out of town for a weekend vacation or maybe for a few weeks and no one is there to feed your fish, then the question arises who will take care of your fish or if you are running a big fish breeding center or you running a big fish aquarium where you have multiple tanks containing various fishes inside it. In this case, we can use an automatic fish Feeder to reduce human intervention here we are using the Arduino board as a controller. Fish feeder we are going to make a very simple automatic fish feeder using millis() function. We don't require WIFI, Bluetooth, or IR remote to control the fish feeder. We also don't require any mobile app to control it. We are going to make it fully automatic without manual involvement. This type of fish feeder helps to reduce manual work. The fish food will dispense the fish food regularly at a fixed set time. We can feed the fish even if you are not available at the house or you are out of town. Such an automatic system does not need any extra maintenance. it can be used for both small as well as big tanks of any shape. The fish feeder will dispense food every after 24 hours. When the time triggers it will automatically feed the fish. This system can be operated by both DC adapters and by battery (when you are away from home).

Parts required –

  • Any empty bottle
  • Servo motor
  • Arduino board
  • Wires
  • Dc adapter or battery
  • Cardboard
  • Glue/double tapes/ cello tapes

First take any empty bottle, in my case I have taken an empty power bottle then take a double tape and apply it near the neck of the bottle. Then stick your servo motor on a double tape. We have to be accurate in the degree of rotation so we use a servo motor.

After applying the servo motor on double tape, now we cut a shape (any shape) in my case I have cut in a square shape from cardboard which will act as a closure to the bottle opening from where fish food will be released.  

After cutting the square shape of cardboard we will place that cardboard piece between the servo motor and bottle opening and apply some glue to it. The cardboard piece will be attached to the shaft of the servo motor. The cardboard piece will rotate according to servo shaft movement. When the servo motor rotates the shaft away from the bottle opening then fish food will be dispensed and when the servo motor rotates the shaft towards the opening of the bottle then it will act as a closure so that fish food does not fell from the bottle.

After applying glue you can apply double tape on it to provide extra protection from the base side. Allow the glue for drying.

After drying the glue is dry we will use a potentiometer to map the start angle and end angle. Here on serial monitoring, we will know the current angle therefore by rotating the knob of the potentiometer the rotation of the servo motor is determined hence we will know the angle. So after this, we can set the initial rotation angle and final rotational angle.

After knowing both starts and stop angles now we will use millis() function to trigger our servo motor. We can set any time according to our requirement. The advantage of using millis() function is we don’t require any internet connection or any Bluetooth or mobile device to control the fish feeder. millis() does the job automatically so no need for human involvement. millis() function actually returns the current time that has been passed since your Arduino is turned ON. millis() function actually returns values in milliseconds, it will return values till 45 days. After 45 days it restarts Arduino Automatically then again millis() function will return values from 0 till the next 45 days.

Code - 

#include <Servo.h>   // includes servo in-built library
Servo myservo; 
const unsigned long eventInterval = 86400000; //24 hours in milliseconds
unsigned long previousTime = 0;
void setup() {
void loop() {
  unsigned long currentTime = millis();
  Serial.print("Current Time : ");
  if (currentTime - previousTime >= eventInterval) 
  int read_angle =;
  Serial.print("Servo Angle : ");
  Serial.println(" deg ");
   /* Update the timing for the next time around */
    previousTime = currentTime;

First, we include an in-built servo library in our code. Then we created an object from the servo library as my servo. Inside the void loop, we have attached pin 9 of Arduino to the servo motor. We have declared the event interval variable where we have stored 24 hours in milliseconds. So our fish food will operate every 24 hours. We have also initialized the previous time variable to store the passing time and subtract it from the current time. We have set the initial angle at 95 degrees (close) by the servo.write(95);

In the void loop initially, we store the value of millis() in variable name current time, we have a user data type of unsigned long as millis() function returns a huge number. millis() function returns value till 45 days but after 45 days it restarts the Arduino Again. Here we have used the if the condition that will check current time – previous time and the result will be compared with our desire 24 hours in milliseconds if current time – previous time is greater than equal to desire value 86400000 milliseconds (24 hours) than it will rotate servo motor to 50 degrees (open) so fish food will be dispensed. We have introduced a delay of 2000 milliseconds means fish food from the feeder will dispense for 2 seconds then it will rotate to an initial 95 degrees (close) and fish food will not get released from the fish feeder. In this way, the fish feeder works automatically using millis() function.

Conclusion –

This is fish feeder is a simple porotype project, later this project can be made using a 3D printer. Such type of fish feeder is very cheap and easy to make, with No requirement of extra material. Anyone can build this type of fish feeder at home only. The advantage of such a fish feeder is it is fully automatic, with no need for human involvement. If you are running a big fish breeding center or you are out of town for a few weeks or you want to use it in your regular home fish tank then this type of fish feeder is very useful. Such a fish feeder does not require Wi-Fi or Bluetooth or any mobile app. This fish feeder uses millis() function which acts as a timer to dispense fish food. This fish feeder requires a DC adapter for powering Arduino or battery when you are out of town and No one is present in the home to feed the fish. Hence your fish is survive even if you are out of the house. 

"I hope you find this IoT blog very helpful to you. In the upcoming lesson, we will see more about IoT Projects till then bye. See you all in my next blog."

Close Menu