Detecting changes in light levels is required in many applications. There are many different types of sensors that help us measure changes in light.

An LDR (Light Dependent Resistor) is one of those components that has the ability to detect light levels.

But, is an LDR an input or output? The LDR is an input device which is connected to a device capable of processing such as a Microcontroller or Microprocessor. It is an input device because it provides information to the processing device. Information flows from the LDR to the microcontroller/microprocessor. 

Output devices are things the processing device sends information to or controls in one way or another. Devices like motors, Light Emitting Diodes, Speakers etc. 

Input and Outputs

To better understand why an LDR is an input, it will help to understand the basics of Inputs and Outputs. 

Inputs and Outputs are commonly used in embedded systems. The embedded system includes a processing unit (microcontroller or microprocessor), input and outputs.

A computing system is a great example of an embedded system that includes a processing unit, input and outputs. 

The inputs of the computer include the mouse, keyboard, usb drive, headphone jack etc.

Outputs include the screen, printer, speakers, etc.


An input is a device that receives information from the physical world and sends it to the processing system.

In the computer system, the keyboard receives an ‘input’ from the physical world in the form of a button press. Whenever you push a button, information is sent to the processing unit that lets it know what button has been pressed.

The flow of data starts from the outside, and works its way in. 

An input can be a button/switch, or, a sensor. There are a range of sensors available capable of sensing the physical world which range from sensing temperature to light levels (like the LDR) and much more. 


While an input receives information from the outside world and sends it to the processing system, an output works in reverse.

The flow of data starts in the processing unit and data is sent to the output. 

An output is a device that gets controlled by a microcontroller or microprocessor depending on circumstances (or statements) which are determined by program code. 

For example, you might write a piece of code that turns on an LED (light emitting diode) every 10 seconds.

These circumstances can also be influenced by inputs. 

Say, you want to turn on a fan every time it gets hot. A temperature sensor can sense the temperature every time it exceeds a threshold temperature and send this information to the processing unit. The processing unit can then turn on the fan.

Common outputs used in embedded systems include:

  • Motors (stepper motors, servos, brushless DC motors)
  • Displays (LCDs, OLED’s)
  • Pumps
  • Actuators

Why the LDR is an input

So, why is the LDR an input? 

The LDR is an input because it provides an embedded system with information it receives from the external world. 

It is a type of resistor whose resistance varies depending on light intensity. Lower intensity light levels generate higher resistances and vice versa.

The information that it outputs is sent to a processing device which will process it accordingly depending on the needs of the application. 

As you can see, the LDR is an input because the flow of information starts from the outside world (this case light) and works its way inward towards the processing unit via the LDR. 

Common configurations of LDR as an Input

There are two typical configurations an LDR is used as an input ; using a Micrcontroller and using an Transistor.

Configuration #1 : Using a Micrcontroller

Since the resistance of LDR varies depending on light intensity, its common configuration as an input is a voltage divider.

The purpose of a voltage divider is to scale down a voltage. When an LDR is used instead of a fixed resistor, the output voltage of the voltage divider varies as the resistance of the LDR changes.

This voltage can be used as input for a microcontroller’s ADC (analog to digital converter). The ADC can take this analog voltage and convert into a digital signal that the microcontroller can process. 

Configuration #2 : Using a transistor

Another common configuration an LDR is used as input is with a transistor and other passive components such as resistors, diodes and capacitors. This configuration does not use  a microcontroller.

A simple circuit (as seen below) uses the LDR as an input to the transistor to turn on an LED (at the output). 

Low light levels (when it’s dark) cause the LDR to increase in resistance, which causes the voltage at the base of the voltage to decrease leaving the transistor off. Due to this, no current can flow through the LED,

When light levels increase, the resistance of the LDR decreases causing a higher voltage at the base of the transistor and thus turning it on. Now a current can flow through the LED turning it on.

Can an LDR directly input to a microcontroller

As you saw above, a microcontroller has ADC inputs capable of converting analog voltages to a digital signal. 

However, it does not have any capabilities of reading resistances and since an LDR changes its resistance, it cannot be directly connected to a microcontroller. 

It will need to be used in a voltage divider configuration as mentioned above. 

Applications where an LDR is used as an input

The LDR is a versatile component used in many applications as an input. It can be found in your home, in many businesses and outside on the streets.

Below are some common LDR applications.


The first application where an LDR is used as an input is burglar alarms. These types of alarms tend to be placed at doorways.

A laser is placed on one side of the doorway and its beam aimed at LDR on the other side of the doorway. When the beam is broken (ie. when someone walks past it) the resistance of the LDR changes and an alarm is triggered.

These types of alarms are usually found at storefronts and businesses to indicate to the people working that someone has entered.


Street Lights help illuminate the roads so that we can drive, and walk safely during the night.

The sun rises and sets at different times of the day. So light levels vary accordingly. Having someone manually turn on and off these street lights is very inefficient. 

LDR’s are placed in street lights and help them sense light levels so they can turn on and off automatically without the need of a human operator, thus making them more efficient. 

Solar night lights

You might have some in your garden, or might have seen them in other people’s gardens in your neighbourhood. 

Solar night lights are a great way to add some personality to your front and backyard. Just like the street lights they can also help you navigate your garden safely during the night.

They also have LDR’s that help detect light levels so they automatically turn on when light levels drop, saving you the hassle of having to turn them on manually. 

Using an LDR also helps the solar night light conserve power, as it only has to remain on when necessary. 

Smoke alarms

Yes, you read that right. Smoke alarms also use the LDR as inputs to detect when a fire is present. 

Fires pose a great threat anytime of the day or night, but even more so during the night time when you are sleeping. If a fire starts when you are sleeping you might not be aware of it until it’s too late. 

Having a smoke alarm in your house can be the difference between life and death.

A smoke alarm that uses an LDR works in similar principle to the alarms mentioned earlier. 

An LED shines a beam onto the LDR. When that beam is broken by smoke, an alarm is triggered. 

What does an LDR input into?

If an LDR is used by itself, it is quite redundant. All it is capable of doing is changing its resistance as light levels vary. 

It needs to be used as an input with a device like a microcontroller which can process and make sense of these changes in resistance. 

As you saw earlier the voltage divider is the most common configuration the LDR is found in when used as input to a microcontroller or transistor.

Can an LDR be used as an output?

The LDR’s main function is to react to changes in light levels which means it can only be useful when used as an input in the configurations using a microcontroller or transistor.