Light Dependent Resistor (LDR) is essentially a photoresistor, which means its resistance is dependent on the amount of light it receives. We can use an LDR to detect the light level in the environment. If you are looking for an inexpensive solution to detect day and night, an LDR would be a good choice.
In this tutorial, we will learn how to make a light sensor using an LDR with Arduino to control a bulb based on the light conditions of the room or outside area.
Connect the wiresbetween the LDR and the Arduino and the led as shown in the image below.
Connections from the Arduino to the breadboard:
• Arduino GND pin → Breadboard ground line
• Arduino 5V pin → Breadboard 5V line
Connections from the LDR:
• First pin → Breadboard 5V line
• Second pin → 10KΩ resistor → Breadboard ground line
• Common pin between LDR and the 10KΩ resistor → Arduino pin A0
Connections from the LED :
• LED anode pin → Arduino pin 2
• LED cathode pin → 330 ohm resistor first pin → Breadboard ground line
Once you’ve uploaded the code to the Arduino board,you will find that if the LDR sensor is placed in the dark, the led will lightup, while if the sensor is placed in light, the led will turn off.: