LDR Sensor Interfacing with LPC2148

In this tutorial we are going to see LDR Sensor Interfacing with LPC2148.


Before start this tutorial we should know below topics. If you know already, please go further.

Components Required

  • LPC2148 Development Board
  • LDR Sensor
  • LED
  • LCD Module


The dominant of street lights, outside lights, a number of indoor home appliances, and so on are typically operated and maintained manually on many occasions. This is not only risky, however additionally leads to wastage of power with the negligence of personnel or uncommon circumstances in controlling these electrical appliances ON and OFF. Hence, we can utilize the light sensor circuit for automatic switch OFF the loads based on daylight’s intensity by employing a light sensor. This article discusses in brief about what is a light dependent resistor, how to interface with LPC2148.

What is a Light Dependent Resistor?

An LDR or Light Dependent Resistor is also known as photo resistor, photocell, photoconductor. It is a one type of resistor whose resistance varies depending on the amount of light falling on its surface. When the light falls on the resistor, then the resistance changes. These resistors are often used in many circuits where it is required to sense the presence of light. Resistance will be decrease when the light increases. That means, In day time the output resistance will be less compared than night time.

Working Principle of  LDR

This resistor works on the principle of photo conductivity. It is nothing but, when the light falls on its surface, then the material conductivity reduces and also the electrons in the valence band of the device are excited to the conduction band. These photons in the incident light must have energy greater than the band gap of the semiconductor material.This makes the electrons to jump from the valence band to conduction.

These devices depend on the light, when light falls on the LDR then the resistance decreases, and increases in the dark.When a LDR is kept in the dark place, its resistance is high and, when the LDR is kept in the light its resistance will decrease.

The figure below shows the curve between Resistance Vs Light Intensity curve for a particular light dependent resistor.

Applications of LDR

Lighting switch

The most obvious application for an LDR is to automatically turn on a light at a certain light level. An example of this could be a street light or a garden light.

Camera shutter control

LDRs can be used to control the shutter speed on a camera. The LDR would be used to measure the light intensity which then adjusts the camera shutter speed to the appropriate level.

LDR Sensor Interfacing with LPC2148

LDR Sensor is a Analog Sensor. So we need to use ADC for interfacing. Please go through ADC tutorial.

Circuit Diagram


  • RS :  P1.16
  • RW : P1.17
  • EN : P1.18
  • Data Lines : P1.24 – P1.31


  • P0.4 (ADC0.6) : LDR Sensor’s one end


  • P0.31 – LED

Source Code

This source code will control the LED based on the Light Intensity. If Light Intensity is high, it turns OFF the LED and If Light Intensity is Low it turns ON the LED.


LDR Sensor Interfacing with LPC2148

3.5 4 votes
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x
%d bloggers like this: