itzikoi
Published © MPL-2.0

Smart automatic fish/pet feeder

DIY feeder, very smart and modular, for ponds, aquariums, cats and dogs or birds, and can work with every kind and size of food.

AdvancedFull instructions provided150
Smart automatic fish/pet feeder

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
IR receiver (generic)
×1
JustBoom IR Remote
JustBoom IR Remote
×1
Stepper Motor, Bipolar
Stepper Motor, Bipolar
×1
Dual H-Bridge motor drivers L298
SparkFun Dual H-Bridge motor drivers L298
×1
Jumper wires (generic)
Jumper wires (generic)
×1
High Accuracy Pi RTC (DS3231)
Seeed Studio High Accuracy Pi RTC (DS3231)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Schematics

stepper diagram

RTC scheme

IR receiver

IR receiver connect to gnd and 5v and the third pin to pin 2 in arduino nano board

Code

fishFeed_mainCode.ino

C/C++
  // This code written by Itzik Ifergan, all right reserved.
  // I hope you find this code useful. :)
 
  #include <Time.h>
  #include <Wire.h>
  #include <IRremote.h>
  #include <DS1307RTC.h>
  #include <Stepper.h>
  
  #define feed_command 41565 //IR number for feeding, this number can change according to the remote you are using.
  
  Stepper myStepper(200, 8, 9, 10, 11);
  
  char t[32];
  char d[32];
  int morning_hour = 07;
  int morning_minute = 55;
  int absolute_second = 02;
  int noon_hour = 12;
  int noon_minute = 00;
  int afternoon_hour = 16;
  int afternoon_minute = 00;
  int TimeFeed = 5000; // delay time between motor pulses
  int receiver_pin = 2; // Pin in arduino for receive the input from the remote.
  int skipMeal = 0;
  int Motor_steps = -300; // Direction of round, and number of steps.

  IRrecv receiver(receiver_pin);
  decode_results output; // "output" is vareiable that equal to the input from the remote. 
  
  void setup() 
  {
    Serial.begin(9600);
    Wire.begin(9600);
    
    setSyncProvider(RTC.get);   // the function to get the time from the RTC
    receiver.enableIRIn();
    myStepper.setSpeed(150);
    
  if(timeStatus()!= timeSet)
     Serial.println("Unable to sync with the RTC");
  else
     Serial.println("RTC has set the system time");
}
 
   
  void loop()
  {
    //printing Time and Date in serial port.
    sprintf(t, "%02d:%02d:%02d", hour(), minute(), second()); // Define "t" as time string.
    sprintf(d, "%02d/%02d/%02d", day(), month(), year()); // Define "d" as date string.
    Serial.println(d);
    Serial.println(t);
    delay(1000);
    
    //Initial process in case of receiving triger from remote.
    if (receiver.decode(&output)) 
    {
      unsigned int value = output.value;
      if (value == feed_command)
        {
          skipMeal = 1; // determine flag to cancel the next feeding.
          for(int i=0; i<6; i++) // Loop rotate the motor 5 times.
          {
            Serial.print(skipMeal);
            myStepper.step(Motor_steps);
            delay(TimeFeed);
          }
        }
    }
         
   //first feeding at the morning
    if((hour()== morning_hour) && (minute()== morning_minute) && (second() == absolute_second))
      {
        if (skipMeal==0) // Checking if the fish already ate before 
        {
          for(int i=0; i<6; i++) // Loop rotate the motor 5 times.
          {
            Serial.print(skipMeal);
            myStepper.step(Motor_steps);
            delay(TimeFeed);
          }
        }
        else if(skipMeal == 1) // if the fish already ate
        {
            skipMeal=0; // reset the feeding flag to "0" for the next feed
            Serial.println(skipMeal);
        }
      }

    //Second feeding at the noon
    if((hour()== noon_hour) && (minute()== noon_minute) && (second() == absolute_second))
      {
        if (skipMeal==0) // Checking if the fish already ate before
        {
          for(int i=0; i<6; i++) // Loop rotate the motor 5 times.
          {
            Serial.print(skipMeal);
            myStepper.step(Motor_steps);
            delay(TimeFeed);
          }
        }
        else if(skipMeal == 1) // if the fish already ate
        {
            skipMeal=0; // reset the feeding flag to "0" for the next feed
            Serial.println(skipMeal);
        }
      }
    //Third feeding at the afternoon
    if((hour()== afternoon_hour) && (minute()== afternoon_minute) && (second() == absolute_second))
      {
        if (skipMeal==0) // Checking if the fish already ate before
        {
          for(int i=0; i<6; i++) // Loop rotate the motor 5 times.
          {
            Serial.print(skipMeal);
            myStepper.step(Motor_steps);
            delay(TimeFeed);
          }
        }
        else if(skipMeal == 1) // if the fish already ate
        {
            skipMeal=0; // reset the feeding flag to "0" for the next feed
            Serial.println(skipMeal);
        }
      }
      
   receiver.resume(); // Listening all the time for input from remote.
  }

Credits

itzikoi

itzikoi

0 projects • 0 followers

Comments

Add projectSign up / Login