Arduino Light Sensor

Table of Contents

A Light Sensor is a device that detects light. It generates an output signal that is proportional to the intensity of light. A light sensor measures the radiant energy present in the wide range of frequencies in the light spectrum. Some of the common frequencies are infrared, visible and ultraviolet.

A Light Sensor is also called as Photo Sensor or Photo electric Sensor as it converts light energy or photons in to electrical signals.

There are different types of light sensors for different applications. A Photocell or Photo Resistor is the common type of light sensor.

A photo resistor changes its resistance when light is incident on it. Hence, a photo resistor is also called as Light Dependent Resistor or LDR.

When there is no light, the resistance of LDR is very high. When there is light incident on the LDR, its resistance decreases.

There are a wide range of applications of light sensors. The applications include scientific research to everyday residential applications like security systems, burglar alarms garage door openers, solar tracking systems etc.

In this project, a simple light sensor is designed using LDR. The project is built around Arduino. The circuit, components and working are mentioned in the following sections.

Circuit Diagram

Arduino Light SensorHardware Required

  • Arduino UNO  [Buy Here]
  • Light Dependent Resistor (LDR)
  • 100 KΩ POT
  • Buzzer

Component Description

Light Dependent Resistor (LDR)

An LDR is a type of variable resistor that change its resistance according to intensity of the light incident on it. Generally, when the intensity of light is less i.e. in dark conditions, the resistance of LDR will be in the order of Mega Ohms (MΩ).

As the intensity of the light increases, it resistance decreases and falls down to few Ohms at maximum intensity of light.

Photo Resistors are semiconductor devices with photo sensitive cells. Photo cells are made with different compounds depending on the frequency of the light and application they are used.

Cadmium Sulphide cell based photo resistors are most common in consumer applications as they are inexpensive. Some applications are night lights, alarm systems, solar tracking systems etc.

Lead Sulphide and Indium Antimonide cell based photo resistors are frequently used for low to mid infrared frequencies.

Germanium Copper cell based light dependent resistors are used in far infrared frequency applications and they are used in infrared based astronomy and spectroscopy.

100 KΩ Potentiometer

This is a variable resistor whose resistance can be varied from 0Ω to 100 KΩ.

Arduino UNO

It is the main controlling part of the project. It has both analog and digital pins. It has 6 analog input pins and 14 digital I/O pins.

Circuit Design of Light Sensor

As the photo resistor or LDR is a variable resistor, a voltage divider network must be used to gets the analog equivalent output from it.

A 100 KΩ POT and the LDR form a voltage divider and the output of the voltage divider is given to the analog input A0 of Arduino.

A buzzer is connected to pin 11 of Arduino.

Working of Arduino Light Sensor

Light Sensors are very useful devices in wide range of applications. One of the common application is an automatic night lamp, where a light bulb is automatically turned on as soon as the sun sets down.

Another good application is solar tracker, which tracks the sun and rotates the solar panel accordingly.

All these applications use a simple photo resistor or an LDR as the main sensing device. Hence, in this project, we designed a simple light sensor that indicates when the light is indicated. The working of the project is very simple and is explained below.

All the connections are made as per the circuit diagram. The code for Arduino is written and dumped in the board. When the LDR detects a light over certain intensity, the Arduino will trigger the buzzer. When the intensity of light decreases, the buzzer is turned off.

The 100 KΩ POT used in the voltage divider network can be used to adjust the intensity levels at which the buzzer is triggered.


int sensorPin = A0; // select the input pin for the potentiometer
//int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
/*void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
// turn the ledPin on
digitalWrite(ledPin, HIGH);
// stop the program for <sensorValue> milliseconds:
// turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for for <sensorValue> milliseconds:
void loop()
if(sensorValue <= 14)



  • Light Sensors are used in variety of applications.
  • They can be used in security systems like burglar alarm systems where an alarm is triggered when the light falling on the sensor is interrupted.
  • Another common application of light sensor is night lamp. As long as the sun light falls on the light sensor, the lamp will be switched off. When the sun light starts decreasing and is completely off, the lamp will be turned on automatically.
  • One of the important applications of light sensors is in generation of efficient solar energy. Light sensors are often used in Solar Tracking systems. The solar panel will be rotated according to the movement of the sun and its intensity.

Similar Articles & Blogs

Explore similar articles on various electronics and electrical topics – 

Logic NOT Function

The Logic NOT Function is simply a single input inverter that changes the input of a logic level “1” to an output of logic level “0” and

Learn More >>

Logic OR Function

The Logic OR Function function states that an output action will become TRUE if either one “OR” more events are TRUE, but the order at which they

Learn More >>

Logic AND Function

In 1854, George Boole performed an investigation into the “laws of thought” which were based around a simplified version of the “group” or “set” theory, and from

Learn More >>

Binary Coded Decimal

As we have seen in this Binary Numbers section of tutorials, there are many different binary codes used in digital and electronic circuits, each with

Learn More >>