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 and when light come, it turn OFF lamp automatic; so no need to press any switch.

Also, it save time and save power and it is small, simple and very low cost system.

Arduino Code:

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:

LDR Light Sensor Circuit Diagram with Arduino

Parts List:

ComponentsValuesQuantity
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 and also LDR change resistance with light.

In dark, LDR resistance go high and voltage is at A0 go low, then Arduino read low voltage and it send HIGH to transistor base.

After that transistor turn ON like switch and a big current go to relay coil and then relay turn ON and give power to lamp and lamp glows.

Furthermore, in light, LDR resistance go low and voltage at A0 go high and then Arduino read high voltage and it send LOW to transistor base.

Now transistor turn OFF, no current go to relay coil and relay turn OFF and cut lamp power and then lamp goes OFF.

Therefore, 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 and 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:

Conclusion:

To conclude, LDR light sensor circuit with Arduino work good to detect light level; also LDR value change when light increase or decrease and Arduino read this value and do action.

Hence, this project simple and useful for automatic light control and light monitoring system.

Exit mobile version