Chicken Coop Controller V2 Software Update

About: I am consultant who spends his spare time dreaming up stuff and reading other people's great ideas. I have a growing family and a very forgiving wife!

Pictures of the previous Arduino Chicken Coop Controller and its new cousin (top).

Over the last 18 months I have been using my Arduino based Chicken Coop Controller to great success with even a few folks out there ready to build their own versions. Since that time I have had a couple of door malfunctions (jamming) and one mechanical malfunction where the connector from the motor to the spindle broke and required glueing (because the door jammed!)

During this time I have had many followers and many thanks to all those who have commented and were keen to understand more about the project. For those who are interested in building this controller I would suggest you read the original instructable which covers the whole project from inception to operation. This Instructable will only cover the electronics and the code.

The instructable brings together a number of ideas that I wanted to originally include and others have asked me to build into the future design. Thanks to all who have urged me to bring out the v2 - sorry for the long wait.

Just to remind you the main features of the original ACCC were:

  • Based on the Arduino architecture for easy prototyping and adaptation to your coop requirements
  • Uses common parts easily found at you local DIY/hardware store/shop such as cheap electric screwdrivers
  • Uses a real time clock (RTC) to maintain time even when the device is temporary disconnected from power
  • Adjusts the opening and closing times of the door according to the current month - you can set it to your own timezones
  • Provides a manual override just in case one of your lovely darlings misses sunset!
  • Provides a min and max temperature reading inside the coop from midnight so you can keep an eye on your brood's welll-being
  • A display which can be switched on and off to read out the current ACCC status and will not disturb your feathered friends sleep at night

Most of the electronic components were sourced from eBay and I estimated (2012) the electronics would cost around £35

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: The New Requirements

At the end of the previous project there were a couple of rough edges I wanted to smooth out:

  • Entering the up and down times for the door was done during programming and I found this needed to be adjusted during the course of the year which meant taking my MacBook into the coop and wiring it up to the Arduino which isn't much fun in the height of winter or summer
  • The up and down times for the door needed to be calculated in minutes from midnight which meant you had to do a quick mental calculation to realise 390 on the display meant 6.30 (390/60)!
  • I though I was pretty pleased with the amount of information I managed to squeeze in the 2 row x 20 character display. However you needed to concentrate to read-off the display as it displayed current then minimum and then maximum readings within about 3 seconds!
  • The system could only cope with one time setting without summer time savings (BST) which wasn't much of a problem as long as you remembered in the summer the coop clock was always going to be an hour behind BST for the UK

Some design suggestions I didn't take on. I drew the line at given the ladies under floor heating suggested by one of my fellow instructable colleagues!!

I suppose I have taken a 'suck it and see' approach in the evolution of the design which has been good and a couple of things came to light in normal day-to-day operation:

  • It was difficult to tell from my lounge window, while I had a beer in my hand, whether the door had gone down. In particular, if it had gone down successfully
  • When I did get a fault I found the motor ran the battery flat because it kept on spinning or even worst was stalled because the rope around the spindle was tight. This almost led to a motor driver burning out
  • If the controller missed the door closed trigger when the door was going down then the motor will continue until it has unraveled all the string and would then proceed to pull the door up! Something to avoid when you are plague with foxes
  • I really wanted to adjust the door up and down times without the use of the MacBook and to use something more simpler than the keyboard in the original design
  • When I originally built the electronics I did most of it myself but since then the building blocks for an Arduino are very cheap so I decide to to use some modules such as RTC (Real Time Clock) £3 and a small Arduino development board £4. Hopefully then others might be brave and take the plunge.

Step 2: Design Changes

The first major design change was the introduction of a menu driven system using one of the available systems for the Arduino. I went for the Phi_Prompt system as I found it was very well structured, adaptable and supported a number of screen and input types, including rotary. It didn't take me long to work out how to migrate my existing code into the structure. More on about the code in the next step.

I decided to substitute the 2 row display screen for a 4 row x 20 character display. The interface uses the standard 4bit interface - although those folks who have 2 row screens with built in keyboard still can use the code but will need to adapt a few parameters so you can scroll up and down to display all 4 rows. I have programmed the back light to stay on for a set period when it enters 'run mode'. That way you can check the times are correct and the temperature probe is working ok before walking away from the coop.

Instead of the keyboard I decide to go for a rotary switch with very basic debouncing circuitry interfaced to an Arduino development board called a Xino. I bought some right angled connector pins and used those instead of the supplied straight ones so I I could hook up the other modules from the side. That meant I can use push hoods to connect the components and modules. Again these leads with hoods are readily available on the internet.

While I had the door out I moved a few things around and created an easily accessible enclosure for the electronics with a door. Specifically I moved the motor driver board into the housing so I could easily access it if I had too. I decide also to up rate the microswitches to something more robust as I had a couple of switch fails mainly due to the weather and cold extremes we have had recently.

Step 3: The Electronics

As I have mentioned before I decided to use modules wherever possible and to make it easier for folks to do it themselves.

I have attached the schematic on how I wired the individual modules. Please note that various pull-up resistors for the probe and switched haven't been included but I have attached the previous schematic for v1 so you can understand how they are connected.

The key modules I used were:

  • Xeno Arduino prototyping board (£3.70) which you can add an ATMega328 chip(£3.00) or the Arduino Uno (£18)
  • ATMel programmer (£5.00) which can load the boot loader and program for you
  • MicroSwitch with Roller Actuator (Micro Switch) (£1.50) x 2off
  • Female to Female Jumper Wires Ribbon Cable (£1.50)
  • 6V 8Ah AGM Sealed Lead Acid Rechargeable Battery (£16.00)
  • Trickle Charger - make your own (£3.00)
  • 5 Pin Digital Push Button Switch Rotary Encoder/ Momentary Push Switch (£2.00)
  • Tiny RTC (£3.00)
  • HD44780 2004 20x4 White Characters LCD Display Module (£6.00)
  • L298N Dual H Bridge Stepper Motor Driver Controller Board (£5.00)


Step 4: Menu Driven - Code

As previously mentioned I used a LCD menu system library produced by Dr Lui - this library is called PHI_Prompt. The reason for this choice is that I wanted the ability to use a simple rotary switch to select certain variables within the program and change them to a prefixed range. For example for each month I can now manually set the up and down door times using the menu system.

I am not going to go in to too much depth in terms of explaining the code just the new features - everything else is similar to the previous code in the first version.

When you open Chicken_Coop_Controller_v2 you are presented with five tabs:

  • Chicken_Coop_Controller_v2
  • Coop_Control
  • Coop_Menu
  • RTC
  • TempProbe


The main labels definitions used within the code are here including the character mapping required by the menu system. If you were to decide to opt out using a rotary switch you could use the previous LCD keyboard (analogue restore network) instead. If you read the PHI manual it explains how you can change the input and output without to much modification to the code - very cleaver.

Global variables and libraries are also defined here. The program is initialised and then the top_menu() function is called to start the system which automatically goes into 'run mode'.


This is were the bulk of the control logic sits when the 'RunController' menu options is selected. The default values for the door up and down times are set. This version now works in hours and minutes - so times are set hour, minute rather than total minutes which I know did confuse folks. In this section I have also added the logic (SetFlashOn) which causes an LED to come on when the door closes correctly and flashes when there is a problem when closing and opening


Here is where the structure and configuration for the Coop_menu sits:

  • Run Controller
  • Set Time/Date
  • Set Door Time
  • Door Up
  • Door Down
  • Door Parameters
  • About

For each menu selection there is a local call function which then calls on the Coop_Control functions. This section is relatively straightforward - well I hope!

I have added a failsafe feature to the door down and up options which keeps track of how long these functions have been running. If they go beyond the set parameter (MotorFailSafe) then the motor is shut down.


This code has been significantly modified so that it works with the DS1307 library. I have also added British Summer Time (BST) conversion logic. At the top of this code I have created 7 years of when the clocks go forward and backward. When the code goes to print the time it checks whether it needs to add an hour on Standard Greenwich Mean Time (GMT). This code also prints the door close and open times and sets the current time for use elsewhere in the code.

Within this code you can also set the Coop time and date using the menu input code. You are force to set time first by rotating and clicking the hour and then minute.


This code is very similar to the previous code in original controller. It reads a OneWired temperature probe and converts into a centigrade reading, then displayed and then compared with previous readings to see if it is a minimum or maximum reading. If so it is stored. The minimum and maximum readers are also then displayed

I have updated the software to run with the new Arduino 1.6.6 environment. I get one warning when it compiles but everything seems to be ok. If you have any problems drop me a line.

Step 5: In Operation

I have managed to cram all the electronics into the door assembly so there is very little for the ladies to peck at. The backlight for the display automatically turns off which can be set from one of the menu options.

In practice the rotary switch works fine but does suffer from the occasional de-bouncing which can be cured with a few resistors and capacitors. I have included a link to a good instructable for those who want pinpoint accuracy as they rotate through the menus and options.

The reality is I seldom take the the controller out of 'run mode' unless I want to stop my little lovelies from coming into the coop while I am doing something.

I have a thin cable coming out of the controller going to the roof where I have used a bright white 5mm LED as the door close signal and fault alarm. I sealed it in with a generous blob of silicon so to keep the damp from the pins.

I must admit I have found the options to change the down and uptime's on the fly a real time saver and the fact that it now displays the time in hours and mins is very helpful. Also it automatically adjusts for British Summer Time which means I know longer get confused as to whether the clock is right is another plus.

Probably the best feature is the flashing LED which one of my followers 'Larry' suggested is a real must. I can just peak out of my window to know if the door went down safely. When there might be a problem it flashes at me to make sure I come to the bottom of the garden to inspect which usually is a missed close door sensor trigger but because of the failsafe for the motors means the door stays down.

As ever I am happy to answer questions and I do hope you have enjoyed this instructable and it helps to stimulate your creative juices to help keep safe your feathered friends.

2 People Made This Project!


  • Made with Math Contest

    Made with Math Contest
  • Multi-Discipline Contest

    Multi-Discipline Contest
  • Robotics Contest

    Robotics Contest

20 Discussions


5 years ago on Introduction


Thanks for this excellent tutorial. I am just teaching myself the workings of Arduinos and how to code them and am just about to get chickens so your project has really got me excited! I was wondering a couple of things; not having used an lcd with an Arduino before could you give me the connection details as I can't work it out. Also do I need to compile your different sketches into one sketch to upload to the ic? Sorry for the questions but I haven't done anything as complex with Arduino before.



2 replies

Many thanks James for your kind comments. You can find the wiring (Schematic) on my previous Instructable on Step 5. There is a ACCC schematic attached to this section.

When you expand the zipped sketch folder and open it under the arduino development environment all of the sketches should appear as tabs and when you go to compile all of the sketches compile into one upload. Hope this is helpful and feel free to email me via instructables

M L GRobot-Chicken

Reply 3 years ago

thanks robot chicken, you are a legend! also this reply has cleared up a few questins I was bothering other users with , my aplogies to whoever I was bugging. My motto is I know nothing... therefore willingness to learn should follow, fingers crossed.


4 years ago on Introduction

Hi Robot chicken,

I have been looking at your designed for a while now and we "opened " our coop in August. Our chickens don't wander free but I still would like to build this automated door.

I have ordered many of the parts yesterday but one difficulty I have is the board itself, you refer to the Arduino XINO and can't find these in the US. I have an Arduino Mega2560. I am trying to figure out how some of the ports you use relate to that board. The 2560 is an extended version of the Uno, basically more ports. Looking at various drawings online the 2560 has the the same ports but I confused where to find them. Your schematics are great but I have a hard time cross referencing them.

Is there any insight you could share here?

Thanks in advance,


5 replies

Reply 4 years ago on Introduction

I'm not sure the answer to your question, but I do have to ask why would you sacrifice an arduino mega just to have it sitting in your coop conrolling this project? You can get a cheap nano clone off ebay for under $3, or sainsmart uno for about $8.00 and save your mega for future projects.


Reply 4 years ago on Introduction

that is a good question, I will do that. I have made progress, I received most of the parts and got the LCD screen to work last night. Working on the temperature sensor now. I am still waiting on the ATM programmer. I don't completely understand its function but I am learning on the way. This is one of those situations where I start with a complex project and have to learn all the parts in between.

Thank you



Reply 4 years ago
Here is a coop door made for the mega, the code is much simpler than the robot chicken version and it uses a photo sensor so no messing with settings and it automatically adjusts to the seasonal light. I am waiting for all my electronic parts to show up from china, but in the mean time I have been tinkering with the code to display the current photocell reading on an LCD and allow you to select the threshold limits for daylight or night. Also a manual override as well as RTC mode instead of based off light are some features I am considering adding.

M L Gcmperos

Reply 3 years ago

Hi cmperos, yes! I was waiting for someone to say light sensor rather than tinkering with time settings! Tell me when it works and I'd love to know exactly how you did it if you have a step by step. I'm new to arduino and microcontrollers so I have no idea where to sink my teeth in. I know "what" I want to achieve basically, but not "how" to achieve it! I'm a pretty deft hand especially when it comes to woodworking and carpentry so I imagine mechanically I will fairly easily get that side of things sussed but electronics, phew! I have so much to learn but I'm very intriguid, very interested and very willing to learn. I have been using Linux and Rapberry pi since 2009 so I'm not unfaniliar to the commandline but each language is not without its differences, again willing to learn, where do I start please. Thanks a million in advance.


hi Peter

Sorry for the delay and hopefully not too late. For cheapness you can use the Arduino Uno board - RC


Reply 3 years ago

I running 1.6.5 and I can not make it compile. Could you uploade the code m´with the new syntax?



Reply 3 years ago

Hi Kaastrup

I need to check out the changes to the libraries since 1.01. Bear with me once I have it working I will send it up to be downloaded. I think the problem is in the menu library I took from someone else - RobotChicken


Reply 3 years ago

I am on 1.7.7 and have compile issues as well. I am working on fixing and will post when figured out. I would prefer to update than to use 1.6.1. Let me know if you have solved.


3 years ago

Thanks for the update RC! I had some RTC issues in addition to the phi_prompts/interfaces updated libraries. I was using a newer DS1307 lib and had to make some changes to allow it to compiles.

Errors were related to RTC not defined in scope. So, I went to the Chicken_Controller_V3.ino and added the following after the pinout definitions:

DS1307 RT = DS1307();

This had errors on its own so I had to replace "RTC." with "RT." across the other .ino files and it fired right up.

I am posting in the event someone else has a similar experience.


4 years ago on Introduction

Thanks for the instructable. I am new to
arduiono/electronics so this is my first "big" project. I am in the
infancy of the project and the first thing I tried was gathering the libraries
and compiling the sketch. This is where I ran into my first issue and figured I
would post the solution I found in case it helps someone else having issues
compiling the project. Basically in one of the latest Arduino IDEs (I'm using
1.6.1) the syntax for PROGMEM changed. From searching I found that a forum
thread that I believe is by the author of the phi_prompts library. Follow the solution in the tread for
Chicken_Coop_Control_V2.ino, Coop_menu.ino and in the library phi_prompts.cpp
(just follow the error list to find the exact locations). Now on to the next


Reply 4 years ago on Introduction

Great intstructable! I am trying to use your code as a jumping off point for my own project. You are the only person I found who has successfully used a rotary encoder with Dr Liu's Phi Interfaces/Phi Prompts. I have an arduino mega 2560, lcd, rtc, and rotary encoder breadboarded and loaded with your code. I'm running into a problem when I try to add the push button function. The button acts as though its is being continually depressed. I've been going over this for many hours and cannot figure out why this is happening. I have tried connecting the button to different pins. The button circuit is fine (I've checked it with other code). Did you have any problems with this?


Reply 4 years ago on Introduction

Hi Kevin

The only real problem I had was the rotary jumping the menu options because I didn't use an RC circuit to smooth out the encoder transitions.

Have you tried using another switch or another push switch to check the logic? You could also add a pull-up resistor to make sure when the switch is released the input pin goes back to 5v. I think you can set the ports to use their own internal resistor depending which board you use.

Hope this helps - RC

fantastic project. I am having trouble connecting the RTC and coop controller sketches. Was wondering if you could give me some pointers