Introduction: Simple Auto Fish Feeder in Ardinuo

I intended to take a holiday trip with my family, but no one take care my fishes, I check out other instructablers decided to build my auto fish feeder, my only principle is simple to make, save water and save power, I found the roller method is much easier to do.

Step 1: Simple Parts

I found an old toothpick tube suitable for the roller, I need the servo and the disk to mount the roller. Of course any parts can be used, most important to save water and save power, I drilled 5 holes 5mm each on the tube, mounted the servo disk on the bottom (no matter up or down), number of holes and how big is the hole concerned how many food to be given.

Step 2: Simple Assembly

Then I build a ply wood bracket to mount the servo and hang the bracket underneath the lamp position, no screws and no glue used, save water save power, fish food can be scattered from the top.

Step 3: Simple Code

The servo motor is controlled by Arduino code, major parts of the code refer to servo sweep example, I intended to feed the fishes once or twice a day, probably at the same time, so I need a timer, I found the millis() function very usable to count the second, to feed once daily I set the counter up to 86400 seconds, no need RTC.

The roller turned by servo motor at 180 degrees, I tested it rolls three times should be enough food, the shake() function will be called three time every 86400 seconds, save water save power!

#include <Servo.h>

Servo myservo; // create servo object to control a servo // twelve servo objects can be created on most boards

int second =0 ;

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

void setup() {

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

myservo.write(pos);

Serial.begin(9600);

}

void loop() {

static unsigned long lastTick = 0;

if (millis() - lastTick >= 1000) {

lastTick = millis();

second++;

Serial.println(second);

}

if (second >= 86400) { //or 43200 for twice a day

shake();

delay(100);

shake();

delay(100);

shake();

second = 0; //reset counter

}

}

void shake() { // roll would be much better, at first I consider to shake it, this example in the Arduino IDE

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

}

}

Step 4: Simple Operation

The servo can direct plug in the Arduino board power, because it only moves once per day. With the holes downward when the servo turned to 180 degrees, simply press reset and wait it carry on until tomorrow, save water save power!