Introduction: Automatic CHICKEN DOOR Dirt Cheap

My goal was to make automatic chicken door as cheaply as possible. In metric.

Things used: [please check if it matches, i bought these things a long time ago]

-2x bearing holder or rail support; inner diameter 10mm
-2x bearing MR105 inner diameter 5mm*10mm
-M5 rod
-6X M5 nuts
-shaft coupler 5mm 5mm
-sink chain; L at least 400mm
-polycarbonate 210X300
-stepper motor 28BYJ-48
-2x L profile as stepper motor holder
-2*650mm alu profile for sliding, edges at 90degrees
-photoresistor sensor module
-some wires with female headers
-Arduino UNO
-some screws
-a board

some links:

https://www.aliexpress.com/item/1PCS-SK10-10mm-Sha...

https://www.aliexpress.com/item/10pcs-lot-MR105-MR...

https://www.aliexpress.com/item/1PC-Metal-Plastic-...

https://www.aliexpress.com/item/5V-Stepper-Motor-2...

https://www.aliexpress.com/item/4-pin-photoresisto...

https://www.aliexpress.com/item/Stepper-Motor-5x5x...

Use this extention to get up to 7% off
https://alibonus.com/?u=429363

Step 1: Assembly

Cut the M5 rod to arround 270mm. Tigheten the screws around the bearing and place it inside the bearing holder, tightening the screw on the holder. Place two screws where chain should start winding and insert the chain. Set up the right bearing holder with a bearing and two nuts. Add two L profiles to the stepper motor, add a coupler and put it in the rod, then tighten the coupler.

Make a hole in the polycarbonate and tighten the other end of the chain with a screw and an electrical connector to secure the chain. Maybe add some rubber or hot glue to prevent unscrewing.

Step 2: Wooden Board

Cut a bigger hole(200mm) at the bottom and smaller one(50mm) at 700mm from the bottom of the board for photocell. Hotglue a transparent lid in the hole; penetrating outside to get more light. Screw in the sliding profile straight. Screw in bearing holders

Step 3: Electronics

Arduino: Stepper

change sequence of pins from Arduino to steppr motor to change direction

pin 4 -in1
pin 5 -in2
pin 6 -in3
pin 7 -in4
Vcc - to plus
Gnd - to minus

Arduino: sensor

pin 12 - Vcc
pin 13 - DO
Gnd - Gnd

Code:

int Pin0 = 4;

int Pin1 = 5;

int Pin2 = 6;

int Pin3 = 7;

int _step = 0;

int t=2100;

int sensorPower = 12;

int sensorPin = 13;

int revs = 24576; //equals 6 turns

int state=1; //0 is doors closed, 1 is open

boolean dir = true;// gre

void setup()

{

pinMode(Pin0, OUTPUT);

pinMode(Pin1, OUTPUT);

pinMode(Pin2, OUTPUT);

pinMode(Pin3, OUTPUT);

pinMode(sensorPower, OUTPUT);

pinMode(sensorPin, INPUT);

}

void loop()

{

digitalWrite(sensorPower, HIGH); //sends power to sensor

int sensorVal = digitalRead(sensorPin);

if (sensorVal==LOW & state==0)

{

for(int i=0;i

{

state=1;

dir=true;

switch (_step) {

case 0:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, HIGH);

break;

case 1:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, HIGH);

digitalWrite(Pin3, HIGH);

break;

case 2:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, HIGH);

digitalWrite(Pin3, LOW);

break;

case 3:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, HIGH);

digitalWrite(Pin2, HIGH);

digitalWrite(Pin3, LOW);

break;

case 4:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, HIGH);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, LOW);

break;

case 5:

digitalWrite(Pin0, HIGH);

digitalWrite(Pin1, HIGH);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, LOW);

break;

case 6:

digitalWrite(Pin0, HIGH);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, LOW);

break;

case 7:

digitalWrite(Pin0, HIGH);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, HIGH);

break;

default:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, LOW);

break;

}

if (dir) {

_step++;

} else {

_step--;

}

if (_step > 7) {

_step = 0;

}

if (_step < 0) {

_step = 7;

}

delayMicroseconds(t);

}

}

if (sensorVal==HIGH & state==1)

{

for(int i=0;i

{

state=0;

dir=false;

switch (_step) {

case 0:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, HIGH);

break;

case 1:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, HIGH);

digitalWrite(Pin3, HIGH);

break;

case 2:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, HIGH);

digitalWrite(Pin3, LOW);

break;

case 3:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, HIGH);

digitalWrite(Pin2, HIGH);

digitalWrite(Pin3, LOW);

break;

case 4:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, HIGH);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, LOW);

break;

case 5:

digitalWrite(Pin0, HIGH);

digitalWrite(Pin1, HIGH);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, LOW);

break;

case 6:

digitalWrite(Pin0, HIGH);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, LOW);

break;

case 7:

digitalWrite(Pin0, HIGH);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, HIGH);

break;

default:

digitalWrite(Pin0, LOW);

digitalWrite(Pin1, LOW);

digitalWrite(Pin2, LOW);

digitalWrite(Pin3, LOW);

break;

}

if (dir) {

_step++;

} else {

_step--;

}

if (_step > 7) {

_step = 0;

}

if (_step < 0) {

_step = 7;

}

delayMicroseconds(t);

}

}

}

Step 4: Done!

Connect stepper motor to ULN2003A and screw the electronics in. Ajust the sensor trimmer to close at desired darkness and insert it in the lid. Done!

Low power battery operated circuit with solar cell is in here:
https://www.instructables.com/id/Solar-CHICKEN-DOO...

EDIT: now available as compact module for sale
https://www.ebay.com/itm/264159127428