Introduction: Fish Feeder Smart Object

About: Hi! I'm sathothy and I live in the Netherlands. I like to make coasters and ballmachines with knex!

I did this project for a optional course that my school provides called "smart objects". The goal of this course is to design and construct a prototype of a smart object of your choosing. What I decide to make is enterily up to my choosing but there are a few criteria which the object must meet:

-The object must interact with the environment
-The object must have atleast 1 sensor
-Atleast one of the components must be produced using a machine available at a fablab (3d-printer, laser cutter, etc.)

I wanted to create something that I would be able to use even after the course is over. So I decided to tackle a problem in my house: feeding the fishes. This is usually something my dad does when he gets up early in the morning. He is always rushing in the morning so sometimes he forgets. I thought that it would be great to have a machine that does it for him.

Step 1: What It Will Do

Before I got started I thought tabout what the object will do and what it won't do. Obviously it will feed the fish everyday but the aim is to make it smarter than just a feeding mechanism that goes of every 24 hours.

The most important part is detecting when the fish have to get fed. I started to look at behavioural patterns. I thought that the fish might swim more to the top when they are hungry since we feed them from the top but there seemed to be no correlation. So detecting when fishes are hungry is something defenitly won't do.

I decided to make it light dependend too. My dad enjoys watching the fish eating and since he is usualy the first one to come down in the morning he is also the first one to turn on the lights.

Besides that I also wanted to build in a vacationmode that will feed the fish every day regardless of the light

Step 2: What You Will Need

Materials:

- 1 Arduino microcontroller (I used Arduino Uno).
- 1 Servo motor (I used Tower Pro MG90S) and arm.
- 1 Led.
- 1 Photocell.
- 3 10k resistors.
- 1 Breadboard.
- A bunch of wires.
- 1 3mm thick piece of triplex. Atleast 240mm x 405mm for the case.
- 1 Magnetix bar en 2 sphere's (or something similar).
-1 funnel. Input diameter ~90mm, output diameter ~15mm.
-1 flexible lid that fits the funnel (after some sanding)

Equipment:

-Lasercutter
-Drill and drill bits(3 and 6 mm)
-Wood glue and glue gun
-Sandpaper
-Tape
-Zip tie's

Step 3: Feeding Mechanism

The feeding mechanism is a funnel that can open or close using a servo motor.

In order to close the funnel I use a metal sphere that is just large enough to close it up at the bottom. This sphere is connected to a magnetic bar and another sphere that sticks out of the bottom of the funnel. When the servo pushes the ball up there is space for the feed to fall trough.

I also made the funnel a bit longer with some tape(with the nonstick side on the inside) . This is to prevent the feed from falling all over the place like is shown in the first picture.The last picture shows the final funnel and plug.

Step 4: The Case

For the case I made a simple case with makercase. The outer dimensions for the case are 150x105x120mm (lxwxh). On the top there is a 90mm hole to fit the funnel. On the bottom there is a 25mm hole for the feed to fall trough. A used a laser cutter at my local fablab to cut the design out of a piece of triplex.

Using some sandpaper I sanded the edge of the large circle til the funnel fit in. It should not be too loose, but also not too tight.

I also had to create some holes on the top for the LED, photocell and button. For the LED and photocell I drilled one 3mm hole for each and for the button I drilled 4 6mm holes for each leg( +wire) to fit trough.

I also had secure my servo into place. To do this put the servo into the desired position. So that the arm of the servo goes trough the center of the hole and the tip of the arm is just over the center. I marked the edges of servo on the wood. I drilled two 3mm holes on either side of the servo and used a small zip tie to lock it into place.

I glued the case togheter using woodglue and it is done.

Step 5: The Electronics

I need a couple of components to make this work:

-A servo to trigger the feeding mechanism
-A button to switch between vacation and normal mode
-A photecell to check if the lights are on
-A LED to show if vacation mode is on

And ofcourse an arduino to control all the components.

These components are connected to the arduino using a breadboard, wires and resistors where they are needed.

The servo is connected to gnd and 5v. It's control wire is connected to digital pin 9.

The button is connected to gnd and 5v. A 10k ohm resistor is between the button and gn is also required. The signal wire is connected to digital pin 2.

The LED's cathode is connected to gnd trough a 10k ohm resistor. The anode is connected to digital pin 4.

One leg of the photocell is connected to 5v, the other is connected to anolog pin 0 and a 10k ohm resistor which is connected to gnd.

To make wiring easier a breadboard is used.

Step 6: The Programming

In order to visualize the programming I made a flowchart which you can see in the picture above. This program does the following things:

-It checks if the button is pressed. If it is it will switch between vacation mode and normal mode.
-Vacation mode is defined by a variable called "vacVar". When vacVar=3 vacation mode is on and the led will turn on. When vacVar ≠ 3 normal mode is on.
-If vacation mode is on it will feed the fish every 24h until the button is pressed again
-If normal mode is on it will feed the fish if 21h has passed since the last meal and the lights are on. This makes it possible to wake up <3h earlier and still see the fish eating.
-If normal mode is on it will also feed if 27h has passed regardless of light. It will alse raise vacVar by 1. This means that if the system doesn't get triggered by light 3 times vacation mode will turn on. This is to prevent the fish from starving if we forget to turn vacation mode on when we are not home.

I wrote this program in the arduino software:

   #include <Servo.h>
unsigned long Time;
unsigned long intervalMin = 75600000;
unsigned long interval= 86400000;
unsigned long intervalMax = 97200000;
unsigned long previousTime=0;

int feedDuration = 1000;

int sensorPin = A0;
int sensorValue = 0;
int licht = 700;

int vacVar=0;
int knop = 2;
int vacLicht = 4;
Servo servo;

void setup() {
 servo.attach(9);
 servo.write(40);

 pinMode(knop, INPUT);
 pinMode(vacLicht, OUTPUT);
 
}
void feed(){
  servo.write(0);
  delay(feedDuration);
  servo.write(40);
  delay(feedDuration);
}

void pressButton(){
  switch(vacVar){
case 3: vacVar=0;digitalWrite(vacLicht , LOW);  delay(5000); break;
default: vacVar=3; digitalWrite(vacLicht, HIGH);  delay(5000); break;
  }
}

void loop() {
if (digitalRead(knop)==HIGH){
pressButton();
}

sensorValue= analogRead(sensorPin);
Time=millis();
switch(vacVar){
case 3:
  digitalWrite(vacLicht , HIGH);
  if  (Time-previousTime >=interval){ 
   previousTime=Time;
    feed();
}
  break;
  default:
   if  (Time-previousTime >=intervalMax or Time-previousTime >= intervalMin and sensorValue > licht){ 
    if(Time-previousTime >=intervalMax){ vacVar=vacVar+1; }
    previousTime=Time;
    feed();
  break;
  }
 }
}

Important to note here is the integer feedDuration. This integer can be changed dependend on how much feed you want to go trough. The higher this is, the longer the funnel will stay open and thus more feed will go trough.

The intervalMin, interval and intervalMax variables are the minimal , regular and maximum time (21h, 24h and 27h in this case) that can pass till the fish are fed. These areconverted into milliseconds since I'm using the function millis to determine how much time has passed.

Step 7: Putting It Al Togheter

Get your gluegun out because that is what this step is al about.

Now that the mechanism, case, electronics and program is complete it is time to put it al together.

To do this I glued the breadboard to right side of the case and the arduino to the back of the case. It is important that the wires do not get in the way of the funnel so I ziptie'd alot of them together to prevent that.

The funnel slides right into place and can also be taken out again. This is important for when I want to refill the machine.

Step 8: Final Test and Conclusion

It is finished and thus it is time to use it.

Overall I'm very happy with the result. But there are a few things that I would do differently of I would ever do another similar project:

  1. More pictures! Whilst making this project I only made around 3 pictures. The rest where taken when it was already finished. Taking pictures while constructing it would've made alot of steps clearer.
  2. More thought in the case. If I would've put de holes for the LED, photocell, button and servo in the first lasercutter design it would've saved me some work and it would've looked alot better.

Besides those points of improvent I still hope you enjoyed reading this!

Arduino Contest 2017

Participated in the
Arduino Contest 2017