Javatpoint Logo
Javatpoint Logo

Arduino LDR

Arduino LDR (Light Dependent Resistor) project uses the photoresistor to light an LED. The LED will light up whenever there is dark or no light over the sensor.

What is photoresistor?

It is defined as a light-controlled resistor, which is also called as LDR. It is a variable resistor that controls the resistance in accordance with the received light intensity. It means, the resistance decreases as intensity of light increases.

Let's start with the project.

Hardware Required

The components required for the project are listed below:

  • 1 x red LED
  • 1 x 220 Ohm Resistor
  • 1 x 10K Ohm Resistor
  • Arduino UNO R3 board
  • Jump wires
  • 1 x photoresistor

We can use any color LED as per our choice.

Structure of the project

The structure of the project is shown below:

Arduino LDR

How to calculate the output voltage using photoresistor?

The structure of photoresistor is shown below:

Arduino LDR

The formula to calculate the dark output voltage is given below:

Arduino LDR


Vin = 5V

Vout = Output voltage

Here, R2 is the resistance connected in series with the photoresistor = 10K Ohm.

R1 is the resistance of the photoresistor.

Note: The resistance decreases with increasing light. Hence, the output voltage will increase. It means that the output voltage calculated at the light will be higher than the output voltage calculated at dark.

Here, dark and light specify the light falling on the sensor.


The connection of the above project is discussed below:

  • Connect the positive leg of the LED in series with the resistor to the pin number 12 of the Arduino board.
  • Connect the negative leg of the LED to the Ground.
  • Connect one edge of the photoresistor to the 5V pin on the Arduino board.
  • Attach a 10K ohm resistance in series with another edge of the photoresistor and connect it to the GND.
  • Connect the edge of the photoresistor to the analog pin A0.

Note: We have connected the LED only to enhance the project. We can also create the project without using the LED. It will not impact the output.


Consider the below code:

Connection Diagram

The connection diagram is shown below:

Arduino LDR


The output on the serial monitor will appear as:

Arduino LDR

LED is one because there is dark over the sensor.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA