Skip to content Skip to sidebar Skip to footer

Widget HTML #1

Basic of LDR Circuit For Light Sensor Using Arduino

Basic of LDR Circuit For Light Sensor Using Arduino

LDR Sensor Circuit For Light Sensor Using Arduino - One of the light sensors that is often used in microcontroller circuits is the LDR.

LDR (Light Dependend Resistor) is a light sensor where the resistance of the resistor will decrease in proportion to the amount of light intensity coming.

In the dark, the LDR has a fairly high resistance, usually Mega Ohms, but when light hits this sensor, the resistance will decrease.

LDR is also known as Photo Resistor.

To be able to use this LDR sensor, we need a pull-up or pull-down resistor depending on the application that we will use.

The basic circuit of this LDR sensor is the same as that of two series resistors, so we will use a voltage divider between the two.

Look at to the LDR sensor circuit as follows:

Basic of LDR Circuit For Light Sensor Using Arduino
Basic Schematic of LDR

When we use this sensor in our project, the thing we need to understand is that we only take the voltage that comes out of the voltage divider result of this circuit.

For example, we want to turn on the lights at sunset and turn off the lights when the sun rises.

From that, we must know how much the output voltage of the circuit is when it is dark and when it is bright.

From the voltage that we get, we enter the value into the program using a microcontroller so that we can drive the relay to turn on/off the lights.


Light Sensor Using Arduino

As a microcontroller board, Arduino is used as a light intensity detection using a light sensor by reading the output voltage of the LDR circuit. 

How can voltage be read by Arduino and generate logic on programming?

Arduino has 6 ADC pins, ranging from pins A0 to A6.

ADC (Analog Digital Converter) is an electronic device that functions to convert analog signals into digital data.

Generally this ADC was in the form of an IC, but now with the development of technology, this ADC device is embedded in a microcontroller such as the ATmega328.

Arduino has an ADC resolution of 10 bits. If given a voltage of 0 to 5V, then the digital value is 1-1023.

Still confused why it could be like that? For more details, please read the article How to Read ADC Value On Arduino Uno Convert It To Voltage.

In the Arduino LDR circuit, the LDR as a sensor is connected to the Arduino on the Analog pin.

For example I use analog pin 0 (A0). Look at to the following picture:

Basic of LDR Circuit For Light Sensor Using Arduino

After the above circuit has been assembled, the next step is to program the Arduino so that it can read the value generated from the LDR.

The basic program for reading the value of this Arduino light sensor is as follows:

#define pinLDR A0

int valLDR = 0;

void setup() {
  Serial.begin (9600);
}

void loop() {
  valLDR = analogRead(pinLDR);
  Serial.println(valLDR);
  delay(500);
}

Please upload the program above, then open the serial monitor on the Arduino IDE.

Then you will see the results of reading the values are as follows:

Basic of LDR Circuit For Light Sensor Using Arduino

Next, you can develop these basic programs into more complex projects.

So this tutorial was made, hopefully this article can help you understand how the light sensor works and program it using Arduino.

Thank you for visiting the website Chip Piko.

Post a Comment for "Basic of LDR Circuit For Light Sensor Using Arduino"