Introduction: Chicken Coop Sliding Door Prototype
So, we recently bought some chickens. As it starts getting dark the chickens will head into the coop for safety and snoozing. At first light they'll be up and about and head out into the chicken run. The problem is; the sliding door to/from the coop has to be manually opened/closed each day. That's what I'd like to automate.
I'd like it to be light sensitive, so you'll definitely need a light dependent resistor (LDR) with 10K resistor, a full servo (with 100uF capacitor) to control the raising/lowering of the door. I'll say that again: a FULL servo. Not a 180 degree one, but a full 360 degree servo. A couple of LED's (with 220 ohm resistors) are nice to show when the door is open/closed. Oh, and an Arduino would be handy too.
I'm also taking this a step further by including a temperature/humidity sensor and LCD screen (with 10K pot for controlling the screen brightness) just for the giggles.
Step 1: The Basic Build
I started by wiring up the servo (and 100uF cap) to the Arduino (a Nano v3 in this case) and added two LED's with 220 ohm pull down resistors. Also added the LDR with 10K ohm pull down resistor.
My code for this is at: http://pastebin.com/wNMaXNkC.
In my code you'll see values for sunUp and sunDown. These are quite subjective to the environment that you're in. I was in a well lit room tinkering on this and it worked OK with the values I'd entered. As the day went on I found the results quite sporadic. This was due to the light in the room getting less and the sunUp and sunDown values being wrong. To check your light levels, open the serial window and check the value for 'light' when the LDR is covered/uncovered.
The two IF statements do the winding/unwinding of the door using a string attached to the servo. I used two screws side by side, but in the final thing I'll replace the screws (and attachment) with a decent bobbin of some sort to save the string getting tangled on the servo.
Only after getting all of that to work did I add the humidity sensor and LCD screen.
Step 2: Hotting Up
With the main task done I added in the humidity sensor and 16x2 LCD screen.
My code for this is at: http://pastebin.com/ES421PHV.
I'm not even going to pretend that I'm super intelligent and wrote all that code. Most of it is copied from the Arduino site and pasted into my hodgepodge code.
If your humidity sensor is a DHT11 then you'll need the info and library at: http://playground.arduino.cc/main/DHT11Lib.
At the moment it checks the temperature every 3 seconds, but I'll change that to several minutes when I install it in the coop.
----
So, now all I need to do is put it all in a box and lengthen the wires. I have a cheap Wansview IP camera in the coop too and plan to put the LCD screen within viewing angle of the camera. That way I can keep an eye on the coop occupants and their living temperature.