Automatic Window Blind – Code & Circuit Diagram

Automatic Window Blind
Automatic Window Blind

In this tutorial we are going to demonstrate how to make an automatic window blind using Arduino and LDR Module. In the daytime the curtain/Window blind will roll down and in night time it will roll-up.

Components Required:-

Circuit Diagram

Automatic Window Blind Circuit Diagram
Automatic Window Blind Circuit Diagram

LDR Module has 3 pins

VCC – Connect this pin to 5V of Arduino Nano

GND – Connect this pin to GND of Arduino Nano

VOUT – This pin will be connected to Ananlog pin A0 of Arduino Nano

DC Motor will be driven by the L293D Motor Driver Module. L293D motor driver will be operated from Arduino Nano. It has 4 Input pins for 2 motors, we are going to use only one motor.

Connection of the L293D motor driver is as follows :

M2a/IN1 – This pin will be connected to the digital pin no 3 of Arduino Nano

M2b/IN2 – This pin will be connected to the digital pin no 2 of Arduino Nano

VCC – Connect this pin to external Battery of 9V

GND – Connect this pin to ground of 9V battery

Working

LDR Module will give a HIGH signal if the Intensity of light is high and it gives a LOW signal when the Intensity of the light is low.

Arduino will rotate the DC Motor in clockwise direction whenever it detects HIGH from LDR Module and windows blind get rolled down, similarly, when Arduino gets a LOW signal from LDR Module it will rotate the DC Motor in anti-clockwise direction and window blind will be rolled up.

The time of rotating the DC Motor will depend on the length of the curtain.

Working Code of Automatic Window Blind


int m1 = 2; // blinds
int m2 = 3;

int ldr = A0;
int a = 0;

void setup()
{
   pinMode(m1, OUTPUT);
   pinMode(m2, OUTPUT);

   
   pinMode(ldr, INPUT);
  
 Serial.begin(9600);
}

void loop()

 {
  if((digitalRead(ldr))==HIGH&&a==0)//output pin high wen dark
  {
    digitalWrite(m1,HIGH);
    digitalWrite(m2,LOW);
    delay(4500);
    digitalWrite(m1,LOW);
    digitalWrite(m2,LOW);
    a=1;
    Serial.println("low light");
    

  }

  if((digitalRead(ldr))==LOW&&a==1)
  {
    digitalWrite(m1,LOW);
    digitalWrite(m2,HIGH);
    delay(4500);
    digitalWrite(m1,LOW);
    digitalWrite(m2,LOW);
    a=0;
        Serial.println("bright light");
 
  }
 }

Output Video

Leave a Reply

Your email address will not be published. Required fields are marked *