Automated dog food system

i want to implement dog feeding system that i can set a specific time to open like a gate or line of dry food so when i am in work my dog has its food

the problem that i face is how can i set specific time in the arduino related to 24 hour in the day to turn on motor or valve for example ??

thanks in advance ,

There are a couple of ways to get the time of day:

  1. Add a real time clock i2c device that has a separate battery, such as this device: You would need some way to set the time, either via serial monitor, or via toggle switches and a 7 segment lcd to indicate the time.

  2. If you are doing it outdoors where a GPS would work, all GPS devices include accurate time information, and you could read the time of day.

  3. If your device is connected to the network (ethernet, wifi, etc.) you can use the internet time protocols to find what the current time is (it probably better just to use these to set a RTC).

You can use the internal timer of the arduion if you use the time library. Here’s an example.

#include <Time.h>

int led13 = 13;
int led = 9;
int nightLight = 7;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  setTime(8,30,41,23,8,2013); // hour minute second day month year
  pinMode(led13, OUTPUT);     
  pinMode(led, OUTPUT);     
  pinMode(A0, OUTPUT);     
  pinMode(nightLight, OUTPUT);     
  digitalWrite(nightLight, HIGH);
  digitalWrite(A0, HIGH);
  digitalWrite(A0, LOW);
  digitalWrite(nightLight, LOW);

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led13, HIGH); 
  digitalWrite(led, HIGH); 
  //digitalWrite(A0, HIGH); 
  delay(100);               // wait for a second
  digitalWrite(led13, LOW);   
  digitalWrite(led, LOW);   
  //digitalWrite(A0, LOW);   
  if(hour()==7 && minute()==58 ){
    digitalWrite(A0, HIGH); delay(140); digitalWrite(A0, LOW);
  if(hour()==7 && minute()==59 ){
    digitalWrite(A0, HIGH); delay(110); digitalWrite(A0, LOW);
  if(hour()==18 && minute()==59 ){
    digitalWrite(A0, HIGH); delay(140); digitalWrite(A0, LOW);
  if(hour()==19 && minute()==45 ){
    digitalWrite(nightLight, HIGH);
  if(hour()==6 && minute()==45 ){
    digitalWrite(nightLight, LOW);

  delay(300);               // wait for a second

Mine runs pretty accurate, but if yours gets off, just hit the reset button at the right time, and it will resysc. (maybe once a month).