For the automatic mechanism in our door we used an open source electronics hardware and software platform called Arduino. Arduino consists of a main "control board" and a breadboard on which you can construct circuts. Smaller "modules" can be added to the control board to expand its functionality (such as running a motor). Our system consists of a control board, motor control module, breadboard, two small motors with gearboxes, distance sensor, photoresistor (a resistor which varies electrical current based on light intensity), and the necessary wires and resistors to connect them all.
Using the photoresistor the system takes in ambient light levels and checks if they are above or below a set threshold (this threshold is calibrated at light levels expected near dusk and dawn). If light levels are above the threshold, the door will open automatically. If light levels are below the threshold, the system will check if the path of the door is obstructed (using the distance sensor) and shut the door if the path is clear. If the path is obstructed the door will not shut as to avoid injuring any chickens. Light levels are checked at relativly large incraments (every 4 minutes) as to reduce the power drained from the battery. This incrament is reduced to a couple seconds for demonstration purposes.