Light Sensor With Arduino | Making a Light Sensor Using LDR | Light Glowing in Dark Using Arduino | Light Dependent Resistor Tutorial With Arduino
by Utsource in Circuits > Arduino
2507 Views, 2 Favorites, 0 Comments
Light Sensor With Arduino | Making a Light Sensor Using LDR | Light Glowing in Dark Using Arduino | Light Dependent Resistor Tutorial With Arduino
Having a Light sensor is always very amazing thing so in this project we will be making a light sensor using LDR and LDR is basically a light dependent resistor which can be used as a light sensor because its resistance depends how much light is falling on it and depends upon how much intensity of light is there it varies its resistance.
So basically if LRD will not get light it will sense it as dark and vice versa bright. So if it is dark the LED will be turned ON and if it is not dark (bright) the LED will remain OFF.
Things You Need
For this instructables we will need following things :
Arduino UNO
LDR (Light Dependent Resistor)
Resistor (100k-1;330ohm-1) (instead of 330 ohm you can go any value from 330ohm to 1000ohm)
LED - 1
Connecting wires
Breadboard
Some Basics of LDR
The most common type of LDR has a resistance that falls with an increase in the light intensity falling upon the device. The resistance of an LDR may typically have the following resistances:
Daylight = 700Ω
Dark = 100kΩ ( these values were for my LDR , your LDR resistance could be different.
Circuit
Intensity of light ↓ - Resistance↑ - Voltage at analog pin↓ - Light turns ON
As per the Arduino code, if the analog value falls below 700 we consider it as dark and the light turns ON. If the value comes above 700 we consider it as bright and the light turns OFF.
Coding Part
int LED = 9;
int LDR = A0;
void setup()
{
Serial.begin(9600);
pinMode(LED, OUTPUT);
pinMode(LDR, INPUT);
}
void loop() {
int LDRValue = analogRead(LDR);
Serial.print("sensor = ");
Serial.print(LDRValue);
if (LDRValue <=700)
{
digitalWrite(LED, HIGH);
Serial.println("It's Dark Outside; Lights status: ON");
}
else
{
digitalWrite(LED, LOW);
Serial.println("It's Bright Outside; Lights status: OFF");
}
}