How to Program an Automatic Fish Feeder on Arduino UNO — Quick, No-Fuss Guide
Fast, friendly, and practical: this guide shows you how to plan, build, wire, program, and test an Arduino UNO automatic fish feeder so your fish are fed reliably without fuss — no advanced electronics degree required, just patience and a screwdriver.
What you'll need
Building an Automatic Fish Feeder with Arduino: A Fun Experiment
Step 1 — Choose your dispensing mechanism
Spoon, drum, or auger? Pick the simplest idea that won’t clog at 3 a.m.Decide how food will move from hopper to tank: pick a servo-driven scoop, a rotating drum with cutouts, or an auger for pellets. Match the mechanism to your food type — flakes, pellets, or granules behave very differently.
Consider how to limit clogs: use steep chutes, anti-bridge shapes, or a small vibrator tap. Factor in hopper size, waterproofing, and ease of cleaning so mold won’t build up. Sketch a simple mockup or 3D-print a prototype piece to verify fit and smooth dispensing before you wire anything.
Step 2 — Collect and prepare parts
Small details save headaches: check screws, clearances, and hopper fit before powering up.Gather your servo, hopper/container, mounting hardware, and any chassis pieces. Dry-fit parts first: mount the servo to the feeder body and ensure the horn reaches the scoop or drum without binding. Modify the hopper mouth if pellets don’t flow — widen the outlet or add a small funnel.
Prepare simple splash guards and a removable drip tray to keep water off electronics. Sand rough edges on 3D-printed or laser-cut parts so pellets don’t crush or jam. Work tidy: label wires, bag screws by subassembly, and lay parts out in assembly order so you don’t hunt for bits.
Step 3 — Wire the Arduino and motor safely
Wiring mistakes are the silent killers — tie grounds, power the servo separately, and breathe easy.Connect the servo signal to an Arduino PWM pin (for example, D9). Tie the Arduino ground and the servo power ground together so they share a common ground. Power the servo from a dedicated 5–6V supply if it draws significant current to avoid browning out the UNO.
Place a capacitor across the servo power rails (e.g., 1000 µF electrolytic) to smooth spikes. Fit a diode (e.g., 1N400x) if you use a separate motor driver for extra protection.
Wire any RTC module on I2C: SDA → A4, SCL → A5, and feed it the correct VCC (check 3.3V vs 5V). Use short, solid jumper wires for signals and thicker wires for power. Double-check every connection before powering up to avoid smoked components.
Step 4 — Upload code and set feeding schedules
Schedule like a pro — tiny code tweaks give you reliable daily feedings while you sleep.Install the Arduino IDE and open a basic feeder sketch. Load the Servo library and write a clear dispense()
function that moves the servo to a calibrated angle (example: 0 → 90 → 0), waits (500–1500 ms), then returns.
Use millis() or simple delay-based loops for quick setups. Use an RTC (e.g., DS3231) and the Time library for accurate daily times like 08:00 and 18:00. Implement a scheduler that triggers dispense()
and enforces a safety timeout between feeds.
Include Serial.println() for time, state, and errors. Add a calibration mode toggled by a button or a serial command to adjust angles and portion counts on the fly.
Keep functions modular so you can change schedule logic without rewriting hardware code.
Step 5 — Calibrate portions and test thoroughly
Measure, tweak, and repeat — overfeeding is easy; precise dispensing takes a few tests.Calibrate how much food each servo action releases by running controlled trials. Use a cup or tray and run 10–20 dispenses, then weigh the food or count pellets to find servings per rotation (example: 15 pellets ≈ 1 serving).
Adjust servo movement and timing until portions are consistent:
Simulate scheduled runs and test reset behavior between dispenses to avoid jams when the hopper is full. Simulate many cycles to spot wear, and finally observe live feedings to ensure no food falls onto electronics or into the tank water.
Step 6 — Install, secure, and plan maintenance
Mount once with common-sense backups: battery backup, easy cleaning, and fail-safes keep fish happy.Mount the feeder above the tank so food drops cleanly into the water and away from electronics.
Clamp the unit to the hood or use an L-bracket bolted to a nearby rail for solid stability (example: C-clamp to the aquarium rim).
Weatherproof exposed electronics with a small plastic project box and silicone around seams; route wires through a grommet.
Add an RTC coin battery or a small UPS to keep schedules during outages, and install a manual feed button for guests to press.
Schedule routine cleaning to prevent mold and jams and leave the hopper easy to open for quick refills.
Ready, set, relax — automated feeding done
You now have a reliable plan: mechanism, wiring, code, calibration, and maintenance. These steps make your Arduino UNO feeder deliver portions on schedule, keep fish healthy, and let you travel worry-free. Ready to relax and enjoy peace of mind today?
Mounting tips? I put mine on the rim with a 3D printed bracket but after a couple of days the vibrations loosened it.
Step 6 says ‘install, secure, and plan maintenance’ — can we have more specifics like recommended screw types, periodic checks, and humidity protection? My tank room is a bit humid.
I used stainless self-tapping screws and a thin rubber gasket between bracket and rim. Also put the electronics in a small sealed box with foam for desiccant packs.
Good point — I’ll expand Step 6 with recommended mounting hardware (stainless screws, rubber washers), routine checks (weekly for the first month, then monthly), and ideas for moisture protection like silicone conformal coating for the circuit board.
Desiccant packs are a lifesaver. Replace them every few months if the room’s humid.
Great walkthrough — loved the clear steps. A few notes from my build:
1) I used a micro servo for portion control (easier and cheaper), but if you want bigger pellets go with a geared DC motor.
2) Make sure your power supply can handle the motor start current, otherwise strange resets happen during Step 3 (wire the Arduino and motor safely).
3) Calibrate portions several times — I had to tweak the code in Step 5 three times before it was consistent.
Overall: quick, no-fuss-ish 😉, but still expect to test and tweak.
Totally agree on the separate supply. I fried an UNO once when the motor drew too much during startup 😬
Thanks for the detailed tip, Alex — good call on the motor start current. I should add a short note on using a separate power supply and common ground in the guide.
Did you add a diode or snubber for the DC motor? I found back-EMF caused weird behavior until I added protection.
Pretty solid instructions on wiring. One thing I had to remind myself: always disconnect power when re-wiring the motor — even a second with the wrong connection can short stuff.
I also added some heat-shrink and zip-tied everything thanks to Step 6. Safety first!
Absolutely — I’ll expand Step 3 with a short checklist for safe wiring and recommended fuses or PTC resettable fuses.
Build complete. The feeder works AND my cat thinks it’s a new snack dispenser for him. Not sure who benefits more. 😂
I had issues with motor jitter and inconsistent portions. Fixed it by:
– Using a larger decoupling capacitor on the motor supply
– Switching from analogWrite PWM at 490Hz to a lower frequency for my geared motor
– Adding short delays between steps when rotating the dispenser
After that it became very reliable.
What size capacitor did you use? I’m setting mine up this weekend.
Does adding the cap help reduce Arduino resets too? I’ve seen brownouts when the motor starts.
I used a 470µF electrolytic near the motor supply and a 0.1µF ceramic across the terminals. Worked well for me.
Fantastic troubleshooting — I’ll add a troubleshooting subsection with your fixes. Motor noise and PWM frequency are often overlooked.
Nice — I tried 220µF first and still had issues. Upgraded to 470 and it smoothed things out.
Quick question: has anyone integrated remote scheduling (phone app or web) instead of just fixed times in the code? Thinking of adding an ESP8266 for OTA and schedule changes.
Yes — adding Wi-Fi (ESP8266/ESP32) or Bluetooth lets you update schedules remotely. I’ll add a short appendix mentioning OTA, and examples using MQTT or a simple REST endpoint.
I used an ESP8266 with a small web UI and MQTT. Works great but remember to keep a local fallback schedule in case Wi‑Fi drops.
Step 5 (calibrate portions) is underrated. I ran 50 test feeds before trusting it overnight. Also log each dispense to serial during testing so you can spot anomalies quickly.
Excellent advice — adding a short logging example and a recommended test count to Step 5. Thanks, Tom!
Heads-up: I followed everything but my fish got overfed the first day because I miscalibrated. Maybe include a recommended test pattern in Step 5 (like feed 1/4, wait 30 min, adjust) and a warning about pellet sizes.
Also, consider a photo or diagram for how to secure the hopper — mine fell off after a week of vibrations.
I set the schedule to one small test feed per day for a week before trusting it. Might be overkill but gave me peace of mind.
Same here — better safe than an aquarium feeding frenzy lol.
Great suggestion — I’ll add a section in Step 5 for a standardized calibration routine and mention pellet size considerations. Thanks!