Automatic Chicken Feeder

If you have an Arduino already opening and closing the coop door, you might have it run the feeder too. Not kidding, 1 board can run 100+ do something now and then tasks easily but I would use more boards to not have long wire runs.

Step 1 is to set the time.
Step 2 is to remove the bit that sets the time.
Once set you don't want to reset it again.

Step 3 is to learn how to use time and set the trip points.

Step 4 write the servo routine to rotate.

The timer will change state of a flag.

The flag will start the servo routine.
At the end the servo will reset the flag.

Each step can and should be separate.

Start programming. If you have any questions please post the code using code tags as described in the intro posts for the forum.

Your topics on the same subject have been merged

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a suspension from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

hello this is the code that i did but its not work`#include <TimeLib.h>
#include <DS3231.h>
#include <Servo.h>

Servo servo1;
Servo servo2;
Time t;
int pos = 0;

// Init the DS3231 using the hardware interface
DS3231 rtc(SDA, SCL);

void setup()
{
// Setup Serial connection
Serial.begin(9600);
// Uncomment the next line if you are using an Arduino Leonardo
//while (!Serial) {}

// Initialize the rtc object
rtc.begin();

// The following lines can be uncommented to set the date and time
rtc.setDOW(MONDAY);
rtc.setTime(5, 0, 00);
rtc.setDate(03, 05, 2021);

servo1.attach(6);
servo2.attach(9);
}

void loop()
{
t = rtc.getTime();
// Send Day-of-Week
Serial.print(rtc.getDOWStr());
Serial.print(" ");

// Send date
Serial.print(rtc.getTimeStr());
Serial.print(" -- ");

// Send time
Serial.println(rtc.getDateStr());

// Wait one second before repeating
delay (1000);
{
if ((rtc.getTimeStr() >= 5)) {
{ for (pos = 0; pos <= 180; pos += 1) {
servo1.write(pos);
delay(5000);
}

for (pos = 180; pos >= 0; pos -= 1) {
servo1.write(pos);
delay(2000);
}
}
else if ((rtc.getTimeStr() >= 10)) {
for (pos = 0; pos <= 180; pos += 1) {

servo1.write(pos);              
delay(5000);                       

}

for (pos = 180; pos >= 0; pos -= 1) {
servo1.write(pos);
delay(2000);
}
}

else if ((rtc.getTimeStr() >= 13)) { for (pos = 0; pos <= 180; pos += 1) {

servo1.write(pos);              
delay(5000);                       

}

for (pos = 180; pos >= 0; pos -= 1) {
servo1.write(pos);
delay(2000);
}
}
else if ((rtc.getTimeStr() >= 16)) {
for (pos = 0; pos <= 180; pos += 1) {

servo1.write(pos);              
delay(5000);                       

}

for (pos = 180; pos >= 0; pos -= 1) {
servo1.write(pos);
delay(2000);
}
}

if ((rtc.getTimeStr() >= 5)) {
for (pos = 0; pos <= 180; pos += 1) {

servo2.write(pos);              
delay(5000);                       

}

for (pos = 180; pos >= 0; pos -= 1) {
servo1.write(pos);
delay(2000);
}
}

else if ((rtc.getTimeStr() >= 10)) {
for (pos = 0; pos <= 180; pos += 1) {

servo2.write(pos);              
delay(5000);                       

}

for (pos = 180; pos >= 0; pos -= 1) {
servo2.write(pos);
delay(2000);
}
}

else if ((rtc.getTimeStr() >= 13)) { for (pos = 0; pos <= 180; pos += 1) {

servo2.write(pos);              
delay(5000);                       

}

for (pos = 180; pos >= 0; pos -= 1) {
servo2.write(pos);
delay(2000);
}
}

else if ((rtc.getTimeStr() >= 16)) { for (pos = 0; pos <= 180; pos += 1) {

servo2.write(pos);              
delay(5000);                       

}

for (pos = 180; pos >= 0; pos -= 1) {
servo2.write(pos);
delay(2000);
}
}

} }`ing

Can someone help me with my program because its not working once i uploaded it...

#include <TimeLib.h>
#include <DS3231.h>
#include <Servo.h> 

Servo servo1;
Servo servo2;
Time t;
int pos = 0;

// Init the DS3231 using the hardware interface
DS3231  rtc(SDA, SCL);

void setup()
{
  // Setup Serial connection
  Serial.begin(9600);
  // Uncomment the next line if you are using an Arduino Leonardo
  //while (!Serial) {}
  
  // Initialize the rtc object
  rtc.begin();
  
  // The following lines can be uncommented to set the date and time
  rtc.setDOW(MONDAY);     
   rtc.setTime(5, 0, 00);
  rtc.setDate(03, 05, 2021);   
  
servo1.attach(6);
  servo2.attach(9);
}

void loop()
{
  t = rtc.getTime();
  // Send Day-of-Week
  Serial.print(rtc.getDOWStr());
  Serial.print(" ");
  
  // Send date
  Serial.print(rtc.getTimeStr());
  Serial.print(" -- ");

  // Send time
  Serial.println(rtc.getDateStr());
  
  // Wait one second before repeating 
  delay (1000);
  {
 if ((rtc.getTimeStr() >= 5)) { 
  { for (pos = 0; pos <= 180; pos += 1) { 
    servo1.write(pos);              
    delay(5000);                       
  }
  
for (pos = 180; pos >= 0; pos -= 1) { 
    servo1.write(pos);              
    delay(2000);                       
  }
}
else if ((rtc.getTimeStr() >= 10)) { 
for (pos = 0; pos <= 180; pos += 1) { 
    
    servo1.write(pos);              
    delay(5000);                       
  }
  
for (pos = 180; pos >= 0; pos -= 1) { 
    servo1.write(pos);              
    delay(2000);                       
  }
}

else if ((rtc.getTimeStr() >= 13)) { for (pos = 0; pos <= 180; pos += 1) { 
    
    servo1.write(pos);              
    delay(5000);                       
  }
  
for (pos = 180; pos >= 0; pos -= 1) { 
    servo1.write(pos);              
    delay(2000);                       
  }
}
 else if ((rtc.getTimeStr() >= 16)) {
 for (pos = 0; pos <= 180; pos += 1) { 
    
    servo1.write(pos);              
    delay(5000);                       
  }
  
for (pos = 180; pos >= 0; pos -= 1) { 
    servo1.write(pos);              
    delay(2000);                       
  }
}


 if ((rtc.getTimeStr() >= 5)) { 
for (pos = 0; pos <= 180; pos += 1) { 
    
    servo2.write(pos);              
    delay(5000);                       
  }
  
for (pos = 180; pos >= 0; pos -= 1) { 
    servo1.write(pos);              
    delay(2000);                       
  }
}

else if ((rtc.getTimeStr() >= 10)) { 
for (pos = 0; pos <= 180; pos += 1) { 
    
    servo2.write(pos);              
    delay(5000);                       
  }
  
for (pos = 180; pos >= 0; pos -= 1) { 
    servo2.write(pos);              
    delay(2000);                       
  }
}

else if ((rtc.getTimeStr() >= 13)) { for (pos = 0; pos <= 180; pos += 1) { 
    
    servo2.write(pos);              
    delay(5000);                       
  }
  
for (pos = 180; pos >= 0; pos -= 1) { 
    servo2.write(pos);              
    delay(2000);                       
  }
}


else if ((rtc.getTimeStr() >= 16)) { for (pos = 0; pos <= 180; pos += 1) { 
    
    servo2.write(pos);              
    delay(5000);                       
  }
  
for (pos = 180; pos >= 0; pos -= 1) { 
    servo2.write(pos);              
    delay(2000);                       
  }
}
  

  }  }

Another cross-post merged. @ttmo_00 please follow the forum rules. This is your last warning.

Continuing the discussion from Automatic Chicken Feeder:

Another cross-post merged and @ttmo_00 is now taking a few days break from posting on the forum.

@ttmo_00, I hope that upon your return you will be more respectful of our rules.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.