Site icon Circuit Ideas for You

LDR Light Sensor Circuit with Arduino

This project is for smart LDR Light Sensor Circuit with Arduino.

It can feel light like human eye.

When dark come, it turn ON lamp by itself.

When light come, it turn OFF lamp automatic.

No need to press any switch.

It save time and save power.

It is small, simple and very low cost system.

Circuit Coding:

int LDR = A0;
int relay = 8;
int value = 0;

void setup() {
  pinMode(relay, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  value = analogRead(LDR);
  Serial.println(value);
  if (value < 300) {
    digitalWrite(relay, HIGH);
  } else {
    digitalWrite(relay, LOW);
  }
  delay(500);
}

Coding Explanation:

Circuit Working:

Parts List:

ComponentSpecificationQuantity
Resistors100k 1/4 watt1
330Ω 1/4 watt1
LDR standard type1
SemiconductorsArduino UNO Board1
Transistor BC5471
Relay 5V 1
Diode 1N40071
LED Bulb 230V AC1

LDR and resistor make voltage divider.

LDR change resistance with light.

In dark, LDR resistance go high.

Voltage is at A0 go low.

Arduino read low voltage.

It send HIGH to transistor base.

Transistor turn ON like switch.

Big current go to relay coil.

Relay turn ON and give power to lamp.

Lamp glow.

In light, LDR resistance go low.

Voltage at A0 go high.

Arduino read high voltage.

It send LOW to transistor base.

Transistor turn OFF.

No current go to relay coil.

Relay turn OFF and cut lamp power.

Lamp goes OFF.

This is how it work automatic with light and dark.

Formula with Calculation:

LDR and resistor form a voltage divider.

Vout = (R1 / (R1 + RLDR)) * 5V

In dark, RLDR is high so Vout is low.

In light, RLDR is low so Vout is high.

Example:

Dark: RLDR = 1M = Vout = 0.45V

Light: RLDR = 10k = Vout = 4.54V

How to Build:

To build a LDR Light Sensor Circuit with Arduino follow the below steps:

References:

LDR with Arduino

Exit mobile version