Dawn to Dusk Chicken Door Project
There are many advantages of having an automatic chicken coop door. The door will automatically close at night when the chickens are inside and open in the morning. Not only will they stay warm and cozy, critters like coons and skunks will have a much harder time getting to them. The ultimate luxury to me though is the fact that I don’t need to go out and lock them up and get up at the crack of dawn to let them out.
There is a newer version of this project and you can read about it here.
I used an Arduino clone board for the light sensing and timing, solar panel and battery for power.
This is by no means an original idea, after reading about one on Hack A Day, and realizing that an auto chicken door was the answer to my dreams, I found more links and videos on the web.
Here is the sketch
————————————————————————
/* LDR Chicken Door * ——————
*
* opens and closes a door depending on light conditions
*
*/
int LDR = 0; // select the input pin for the LDR
int pot = 1; // select the input pin for the adjustment potentiometer
int CloseOutput = 8; // select the pin for the LED
int OpenOutput = 7;
int LDRval = 0; // variable to store the value coming from the sensor
int POTval = 0; // variable to store the value coming from the potentiometer
int Counter = 0;
int OpenCounter = 0;
int CloseCounter = 0;
int ManualOpenPin = 2;
int ManualClosePin = 3;
int TestEnablePin = 4;
int OpenLimitSw = 5;
int CloseLimitSw = 6;
int OpenLimitActive = 0 ;
int CloseLimitActive = 0;
int ManualOpen = 0;
int ManualClose = 0;
int TestEnable = 0;
int Delay1 = 10;
int Delay2 = 11;
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
pinMode(LDR, INPUT); // declare the LDR as an INPUT
pinMode(OpenOutput, OUTPUT); // declare the ledPin as an OUTPUT
pinMode(CloseOutput, OUTPUT); // declare the ledPin as an OUTPUT
pinMode(ManualOpenPin, INPUT);
pinMode(ManualClosePin, INPUT);
pinMode(TestEnablePin, INPUT);
pinMode(OpenLimitSw, INPUT);
pinMode(CloseLimitSw, INPUT);
}
void loop() {
ManualOpen = digitalRead(ManualOpenPin);
ManualClose = digitalRead(ManualClosePin);
TestEnable = digitalRead(TestEnablePin);
OpenLimitActive = digitalRead(OpenLimitSw);
CloseLimitActive = digitalRead(CloseLimitSw);
if (TestEnable == HIGH)
{ Delay1 = 50;
Delay2 = 60; }
else
{ Delay1 = 6000;
Delay2 = 6002; }
if (OpenLimitActive == LOW)
{OpenCounter = 70;}
if (CloseLimitActive == LOW)
{CloseCounter = 70;}
if (ManualOpen == HIGH or ManualClose == HIGH)
{
if (ManualOpen == HIGH && OpenCounter < 70)
{
OpenCounter += 1;
digitalWrite(OpenOutput, HIGH);
digitalWrite(CloseOutput, LOW);
}
if (OpenCounter > 50)
{
digitalWrite(OpenOutput, LOW);
OpenCounter = 70;
}
if (ManualClose == HIGH && CloseCounter < 70)
{
CloseCounter += 1;
digitalWrite(CloseOutput, HIGH);
digitalWrite(OpenOutput, LOW);
}
if (CloseCounter > 50)
{
digitalWrite(CloseOutput, LOW);
CloseCounter = 70;
}
}
if (ManualOpen == LOW && ManualClose == LOW)
{
LDRval = analogRead(LDR); // read the value from the light sensor
if (LDRval > 970 && Counter < Delay2) Counter += 1;
if (LDRval < 600 && Counter > 0) Counter -= 1;
if (Counter == 1) OpenCounter = 1;
if (Counter == Delay1) CloseCounter = 1;
if (OpenCounter >= 1 && Counter < 1)
{
OpenCounter += 1;
digitalWrite(OpenOutput, HIGH);
digitalWrite(CloseOutput, LOW);
}
if (OpenCounter > 50)
{
digitalWrite(OpenOutput, LOW);
OpenCounter = 0;
}
if (CloseCounter >= 1 && Counter > 50)
{
CloseCounter += 1;
digitalWrite(CloseOutput, HIGH);
digitalWrite(OpenOutput, LOW);
}
if (CloseCounter > 60)
{
digitalWrite(CloseOutput, LOW);
CloseCounter = 0;
}
}
// print the results to the serial monitor:
Serial.print(“LDRval = ” );
Serial.print(LDRval);
Serial.print(” Cntr = “);
Serial.println(Counter);
Serial.print(” OpenCntr = “);
Serial.println(OpenCounter);
Serial.print(” CloseCntr = “);
Serial.println(CloseCounter);
Serial.print(” ManualOpen = “);
Serial.println(ManualOpen);
Serial.print(” ManualClose = “);
Serial.println(ManualClose);
Serial.print(” TestEnable = “);
Serial.println(TestEnable);
Serial.print(” Delay1 = “);
Serial.println(Delay1);
Serial.print(” Delay2 = “);
Serial.println(Delay2);
Serial.print(” OpenLimitActive = “);
Serial.println(OpenLimitActive);
Serial.print(” CloseLimitActive = “);
Serial.println(CloseLimitActive);
delay(100);
}
————————————————————————
2 Responses to Dawn to Dusk Chicken Door Project
Leave a Reply Cancel reply
You must be logged in to post a comment.
Categories
- Alternative Energy (4)
- Arduino (10)
- Components (11)
- Computers (9)
- Electronics (36)
- MicroControllers (13)
- Netduino (5)
- Program Keyless Entry (3)
- Programming (3)
- Projects (19)
- Uncategorized (3)
- Webmaster (2)
Sponsored Links
Tag Cloud
AC Alternative Energy arduino ARM chicken circuit Components Computer DIY Cortex LM3S811 DC diode diy DNN door DotNetNuke electronics ESC favicon Function Getnerator GLCD how to How to Solder Install Windows 7 IO simulator Itunes Alternative Keyless Entry LDR Learn Learn electronics LED Netduino Oscilloscope Peltier program project Repair LCD Resistor RFID servo smtp sound localization tutorial VB Visual Studio ZuneRecent Comments
- admin on RepRap Prusa Mendel V2 Complete Build
- poppen03 on RepRap Prusa Mendel V2 Complete Build
- My Homepage on DIY Peltier Candle Powered Electric Generator
- Yiğit Özen on DIY Peltier Candle Powered Electric Generator
- John Weaver III on Programming a Replacement Keyless Entry Remote
Login With Facebook
Login With Facebook
You may connect your Facebook account to comment or contribute or you can create a local account below.






Hi,
It’s perfect system that I’m dreaming and looking for.
I’m a novice to arduino. I can get all the parts here in Korea, but I can’t combine them into the whole system just like what you do.
Could you help me make my dreams come true and give the circuit diagram for this sytem ?
Thank you in advance and ciao !
Harrison
I need to revisit this project, the weakest point is the actual mechanical door and crummy little motor I am using, in a week or two when I get it done I will draw up the schematic.