Automatic Curtain/Window Blind using Arduino and LDR

LDR based window blind circuit diagram

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

Description

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

Arduino will rotate the DC Motor in clock wise direction whenever it detects HIGH from LDR Module and window blind get rolled down, similarly when Arduino gets 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.

Components required for this tutorial :

Circuit Diagram

LDR based 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 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

Code

int m1 = 2;
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

 

Hope you like this Tutorial. Share this tutorial with your friends.

Leave a Reply

Your e-mail address will not be published. Required fields are marked *