Using a LDR Sensor with Arduino

Crazy Couple DIY
54 followers
151 Video Views·Sep 21, 2026
Hi Everyone, This is my 1st Arduino's tutorial video.
In this video i am going to show you how to use a LDR or Light Dependent resistor to turn on and off another circuit or a LED.
Wouldn’t it be really cool if whenever a room gets dark, a light bulb automatically turns ON and eliminates the darkness? In this very simple project, I am focusing on eliminating darkness. You can even use this as an emergency lighting system. DIY Factory
For more amazing projects like this please visit: https://diyfactory007.blogspot.com.au/
AI Generated·May contain errors
Hi everyone, this is my first Arduino tutorial video.
In this video I'm going to show you how to use a LDR, or light dependent resistor,
to turn on and off another circuit or a LED.
Wouldn't it be really cool if whenever a room gets dark,
a light bulb automatically turns on and eliminates the darkness?
In this very simple project, I'm focusing on eliminating darkness.
You can even use this circuit for like emergency lighting system or an alarm or something.
The LDR is a special type of resistor which allows a lower voltage to pass through it
whenever it's dark and higher voltage to pass whenever there is a high intensity of light.
We are going to use a 10k resistor along with the LDR to create a voltage divider circuit.
The varying resistance of the LDR is converted to a varying voltage
that the analog pin of the Arduino will then be using in its logic.
For this very simple DIY Arduino project we need
a breadboard, an Arduino Uno Nano whatever is handy,
LED, LDR, a 10k resistor for creating the voltage divider and a 220 ohm resistor for the LED,
few breadboard friendly connecting wires, and a USB cable to upload the code to the Arduino.
Connect the 3.3 volt output of Arduino to the positive rail of the breadboard.
Connect the ground to the negative rail of the breadboard.
Place the LDR on the breadboard.
Attach the 10k resistor to one of the legs of the LDR.
Connect the A0 pin of the Arduino to the same column where the LDR and the resistor is connected.
Since the LDR gives out an analog voltage, it is connected to the analog input pin of the Arduino.
The Arduino with its built-in ADC, analog to digital converter,
then converts the analog voltage from 0 to 5 volt into a digital value in the range of 0 to 1023.
Now connect the other end of the 10k resistor to the negative rail,
and the second leg of the LDR to the positive rail.
Pretty much that's it what we need for this light sensing circuit.
Basic circuit like this can be done without an Arduino as well.
However, if you want to log the value and use it to create charts or run some kind of other logic,
I would recommend using an Arduino or ESP8266 or maybe an ESP32 for this.
Now as we want our circuit to do something in the real world,
other than just displaying the value on a computer screen, we'll be attaching the LED to the circuit.
The LED will turn on when it's dark and will go off when it's bright.
To achieve this, we will place the LED on the breadboard.
Connect the 220 ohm resistor to the long end, the positive end of the LED.
Then we will connect the other leg of the resistor to the pin number 13 of the Arduino,
and the shorter leg of the LED to the negative rail of the breadboard.
Start the code by defining two constants, LED pin and LDR pin for the respective components.
Then write the serial begin.
Now define the pin mode, LED to be the output pin and LDR to be the input pin.
Now in the loop section, read the value of the LDR pin using analog read function.
If the status is less than or equal to 400,
then we are going to turn on our LED and display the status.
Else we will turn off the LED and display the status.
A voltage divider circuit is used to read the varying voltage generated by the varying
resistance of the LDR. The varying voltage is sent to the analog pin of the Arduino.
And if L statement is used to turn on and off the LED,
you can replace the LED with a relay which can then turn on and off a 220 volt bulb,
which would be bigger than just blinking the LED using this circuit.
Thanks again for watching this video. I hope it helps you. If you want to support me,
you can subscribe to my channel and watch my other videos.
Thanks. See you again in my next video.
