Introduction: (AT)tiny Fish Feeder

In this tutorial I'll show you how to make an automatic fish feeder. This is what I use to feed my pets while I'm away and it works pretty well!

************************************************************************************************************
How does it work?

The ATtiny85 controls 2 channels of servos (4 (in parallel) on one channel, 2 (in parallel) on another channel) which will open the gate of each one of the food containers. If you want, you can easily change this configuration by modifying the Eagle Layout I made.

The Feeder will operate on a DC power supply from 6 to 9V.
(Be aware that using a higher value of supply voltage will result in need of heat dissipation for the voltage regulator)

*************************************************************************************************************

I am sorry for the bad image quality (all were HD but it seems that while uploading they get compressed).
This is my first tutorial, any help is appreciated.

I hope you like it!

Step 1: Get the Parts

To make this device, you will need the following:
- 1 Microcontroller : ATtiny85 / ATtiny45
- 1 DIL8 Socket
- 1 Resistor (330 Ohm or 220 Ohm, it's for the LED)
- 1 Voltage Regulator 7805 (look for a low dropout voltage regulator if powering with 6V, LM2940CT-5.0 is fine) 
- 1 DC power adapter
- 2 Capacitors (10microFarad is fine, they're for the voltage reg.)
- 1 to 6 Servos (Small ones preferably)
- 1 to 6 Servo extention leads
- Some wire
- Some thin balsa wood
- Transparent plastic tube (This is the food container)
- Metal wire (aluminium wire)
- Glue
- Double sided sellotape or velcro
- 1 Project Box (70x50x25 mm)
- 1 SPST Switch
- 1 LED
- 1 Self-adhesive PCB Mounting Pillar (if you plan to use one make sure that it's small enough to fit inside the box)
- 1 Barrel Jack
- 1 Male pinhead connectors row
- Stuff to make your PCB : Copper board, etchant, laser printer, iron, soldering equipment, etc.

Appart from this list and if you don't have an AVR programmer, you will eventually need the components of the following tutorial:
https://www.instructables.com/id/Program-an-ATtiny-with-Arduino/
Those are required to program your ATtiny with an Arduino Board!! (and that is how I programmed it)

Step 2: Make Your PCB and Prepare Connectors

Once you've got everything you need you can make your PCB. I won't cover the methods, you can find plenty of instrucables on how to make it on this very website. Personally I think that the toner transfer method works pretty well.


Solder the wires to the switch, the Jack barrel plug and the LED.


Some changes:
-I finally decided to put directly the switch between power input and the board instead of putting it on the board. I just had to short the switch pads I had made on the board. This is really up to you.

I post the schematics and Eagle PCB layout:

Step 3: Code

Now comes the hardest part of this tutorial. As I'm using the Arduino IDE the servo library that comes with it won't work with the Attiny (atmega uses a 16 bit timer while attiny uses an 8 bit timer). If you are not using the Arduino IDE you can check out this website to run your servos:
http://www.cunningturtle.com/attiny4585-servo-library/

Otherwise you will need to create your own servo library (if you do please post it on the arduino website!) or you will have to write the signal that the servo requires. A servo basically needs PPM (pulse position modulation).
How does it work? The length of the "HIGH" pulse will tell the servo which position it has to move to. The "LOW" pulse is requiredbetween 2 "HIGH" pulses and has to be 5-25 ms long
You will have to play around with the pulses length because it depends on you servo, the angle you want to open the gate (dropped food), etc

The food is dropped differently in each channel (aquariums have different sizes). The first channel's servos make a little and quick movement (this is one is for the little aquarium). The second channel's servos make a little wider movement than the previous and does it 2 times. This is to avoid a sudden excessive food dropping.


Comments are welcome!

If you have an arduino and want to program your attiny using it you may want to take a look at this tutorial:
https://www.instructables.com/id/Program-an-ATtiny-with-Arduino/


Some improvements that will be done shortly:

-Using sleep mode to lower the power consumption and run it on a battery

Here is the code:

Step 4: Make the Food Container

You will need to cut some transparent tube, its length will depend on the time you are away and the amount of food your fishes eat.
Make the servo stand in balsa. It has 3 parts, 2 are the same. (see pictures)
Once you glued them you can fit the plastic tube and leave its extremity just where the edge of the top part ends so everything is aligned and the servo gate can come exactly perpendicular to all parts when shut.
The gate can be made from the remaining square from the top part. Cut a bit in the middle of this square to introduce the servo arm and put some glue.

To make the stand  (when everything is dry) you can twist the metal wire around the transparent tube and shape it to your needs.
You can use double sided sellotape to stick the servo to the top of the structure, but before you do so make sure that your attiny won't tell the servo to turn to an angle smaller than 90º otherwise you may damage your setting.

Use double sided sellotape or velcro to fix the servo to the stand.

Improvements that will be done:
-Using an hermetic container and gate because humidity can damage food if left for a long period of time.

Step 5: Make Your Project Box

The box needs to be adapted to this project.
You will need to drill some holes:
- Jack plug hole
- Switch hole
- LED hole

I recommend to use drilling bits with smaller diameter and then use bigger ones, this enables you to drill more accurately.
Place all of these items with wires already soldered to their corresponding position.

Cut some other holes:
- carve 6 holes to fit the the cables of each servo on the sides of the box.

Now assemble the PCB and solder the wires you had on your plug, switch etc to the board.

Step 6: Finish

I recommend to use sellotape to fix your PCB to the bottom of your box or use a mounting pillar (mine did not fit).
Plug as many servo extension cables as you need.

Close the box, plug the servo to the extension leads, fill the containers with food and you're ready to go!

I hope you liked it! Comments are welcome! ;)