It is Very Easy, Cheap and You Need Only One LDR, Resistor and LED. Here is Circuit Diagram and Schematic To Build Automatic LED Control Using LDR and Arduino Project. In previous guides on LDR, we created light measurement instrument and light meter. However, for Arduino Door Bell like project, to add more logic of sensing day and night, we need LDR like basic sensor. This guide is one foundation base and reference on our site for future complex usage.
Automatic LED Control Using LDR and Arduino
We need the following materials:
- Arduino Uno or similar board
- One LDR
- One LED
- One 22 K Ohm resistor
- Breadboard
- Jumper wires
- Optionally multimeter to check voltages at ends
You need to build the circuit like this :
---
If you do not have 22 K Ohm resistor, you need (10K + 10K + 1K + 1K) Ohm resistor following Ohm’s law taught in high school or adjust potentiometer with multimeter to have 22K Ohm resistance.
This is the piece of code aka sketch :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | int sensorReading; void setup() { Serial.begin(9600); pinMode(6,OUTPUT); } void loop() { sensorReading=analogRead(0); if (sensorReading<700) { digitalWrite(6,HIGH); } else digitalWrite(6,LOW); Serial.println(sensorReading); delay(1000); } |
You can adjust the values of sensorReading<700
and delay(1000)
watching serial monitor of Arduino IDE.