LDR Sensor with Arduino

338

In this tutorial, we will learn to turn on light automatically by using LDR Sensor with Arduino.

An LDR sensor (Light Dependent Resistor) is a device that is used to detect light. It detects the light intensity. We use it to control the lights, when there is dark it detects light intensity and blows the lights. As it mainly used in mobiles for auto-brightness and smart street lights.

Components List


Circuit Diagram of LDR Sensor with Arduino

Circuit Diagram of LDR with Arduino

Code for Testing LDR Output

First, we will test the LDR that it is working or not. For this, we will display the LDR output readings on the Serial Monitor. Upload the below sketch and open the serial monitor to see the output readings.


Output Of LDR Testing

Output of LDR Testing

Now after testing the LDR, we will code the Arduino to change the state of LED automatically by using the LDR. When the LDR will detect a high light density the LED will automatically turn off and the LED turns on at a low light density.

Circuit Diagram of LDR and LED

By following the below circuit diagram, connect the LDR & LED with Arduino.

Cicuit Diagram of LDR and LED with Arduino

Code for LDR and LED

By using the below code we can turn on/off lights automatically on detect of light/dark.


Output

Output of LDR and LED with Arduino

Here some more tutorials for you:

Our Youtube Channel

LEAVE A REPLY

Please enter your comment!
Please enter your name here