Related Terminologies

Table of Contents

How to use Photoresistor and its interfacing with Arduino


Table of Contents

We need a sensor that responds to changes in light intensity in its area in order to automate devices whose operation is dependent on the light in the surrounding area. Such devices are known as light-dependent devices, and the sensor that controls them is known as a photoresistor. The term “light detecting resistor” also refers to the sensor’s workings. As a result, the photoresistor and Arduino Uno have been used to demonstrate how to control the LED in this article. The use of a photoresistor is important because it can control lights and other light-dependent devices without human intervention and help save electricity.

What is a photoresistor?

We can deduce from its name that it is also a type of resistor whose resistance values change in response to changes in the surrounding light intensity.

How does a photoresistor work?

The photoresistor is a type of semiconductor device in which the electrons in the valence shell break their bonds and become free electrons as light intensity increases. As a result, holes form, allowing electricity to flow through the device. Normally, there is no current flowing when the intensity of the light is low because the resistor has a high resistance.

However, the photoresistor functions because as the light intensity rises, current begins to flow, decreasing the resistance.

How to control the LED using photoresistor (LDR) with Arduino

A photoresistor makes it easy to control the lights; all we need to do is set the threshold value in the microcontroller code that will cause the LED to turn on and off. Making automatic street lights that automatically turn on after sunset and off when the sun rises is a practical application of a photoresistor.

Therefore, in order to make LED operation dependent on light intensity, the following components will be required:

After listing the components, we designed the circuit that will control the LED with a photoresistor. The circuit schematic is shown in the image below: Breadboard 2 220-Ohm resistors Arduino Uno Connecting wires 1 LED

How to create hardware assembly for controlling LED using photoresistor (LDR) with Arduino Uno

Before we can put the circuit into action on the hardware, we need to define the hardware assembly in the image below:

Using the blue wire, we have connected the photoresistor to the analog pin A0 of the Arduino Uno in order to control the LED. In contrast, the LED was connected using the brown wire on the digital pin 5 of the Arduino Uno.

The 5-volts and ground pins of the Arduino Uno were used to connect the photoresistor to the supply.

Arduino code for controlling the LED using photoresistor (LDR) with Arduino uno

To control the LED automatically we have to program the microcontroller first using the Arduino IDE and the Arduino code is given below:

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Whatsapp

Leave a comment

Over 1.2 Million+ learners impacted worldwide

Learners from 170+ countries have grown in their career through our programs

Explore Programs  

Global Presence

Get in touch to learn more about how you can make the best of your talent

Spend less time worrying about job availability, and more time growing your knowledge. Join DIYguru Program today.

If you’re a current student, please get in touch through the DIYguru dashboard to ask about more details of this Program.

Please note, eligibility for this course is reserved to students who have done related projects and have relevant profiles matching with the pre-requisite of this course.

The DIYguru team hold the right to cancel your admisssion into the program without any explanation via email if found unsuitable and unfit.

Our 7-day money-back guarantee starts from the moment of signup and runs through the free week. Cancellations between days 7 and 30 will get a prorated refund.

Fees for the program is charged only when the admission is approved.


Colleges and Institutions

We're growing rapidly across the country, don’t miss out.

Partner with Us


Corporates and Industries

Have workforce requirement or employee upskilling!

Get in Touch



Work with a team that’s transforming future mobility.

DIY with Us

Book Your Free Session Now

Avail free Guidebook and Expert Mentorship in EV domain curated by Industry experts.

Register to continue..

× Need help?