• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Arduino Light Sensor: Circuit and Code

By Abhishek Ghosh February 29, 2024 9:58 am Updated on February 29, 2024

Arduino Light Sensor: Circuit and Code

Advertisement

A photoresistor, also known as a photoresistor or LDR, is a light-sensitive electrical resistor. The more light falls on the photoresistor, the smaller its resistance becomes. Compared to other light-sensitive electronic components such as photodiodes, photoresistors react very slowly.

A thin layer of the photosensitive semiconductor material is applied to a ceramic substrate by sintering a powder. The electrical connections consist of two comb-like metal surfaces that are then applied and face each other. As a result, the structure of the light-sensitive layer has the shape of a meander, through which the photocurrent flows across the course. The entire assembly is provided with connecting wires and coated or encapsulated with transparent synthetic resin. Hermetically sealed metal enclosures with glass windows and glass penetrations are also common.

Photoresistors often consist of a cadmium sulfide (CdS) or cadmium selenide (CdSe) layer that has about the same colour sensitivity curve as the human eye or photographic film. Cadmium sulfide has the maximum sensitivity at a wavelength of 520 nm, and cadmium selenide at 730 nm.

Advertisement

---

 

Functions and Features of an LDR

 

In semiconductors suitable for LDRs, the internal photoelectric effect is not used but transitions to impurities. When a fault is ionized by the light, it acts like a doping for a few milliseconds and increases the electrical conductivity. Due to the relatively long time it takes to neutralize the fault again, you get a high sensitivity, but also a slow reaction. Due to the involvement of the impurities, the photoconduction is not only dependent on the base material but also on the microstructure and impurities. The semiconductor used does not have to be amorphous.

A few free-charge carriers, which remain even after a long period of darkening, cause a dark current. This can be reduced by lowering the temperature. Photoresistors are characterized by the following parameters:

  • Dark resistance (resistance value of photoresistor in the dark), typically 1 M Ω to 100 MΩ; is only reached after several seconds of darkness
  • Light resistance (resistance value of photoresistor at 1000 lx), typically 100 Ω to 2 kΩ
  • Response time (time that elapses after switching on an illuminance of 1000 lux after darkness until the current reaches 65% of its specified value), typical value 1 to 3 ms
  • Spectral range (material-dependent spectral sensitivity curve)
  • Disadvantage: Temperature sensitivity

 

Circuit Diagram and Arduino Sketch

 

We need the following components for this project:

  1. Arduino Uno or similar board
  2. One LDR
  3. One LED
  4. One 10 K Ohm resistor
  5. Breadboard
  6. Jumper wires

You need to build the circuit like this :

Arduino Light Sensor Circuit and Code

Click here to open the illustration

Now, first, run this code :

Vim
1
2
3
4
5
6
7
8
9
int LDR_Pin = A0;
void setup(){
Serial.begin(9600);
}
void loop(){
int LDRReading = analogRead(LDR_Pin);
Serial.println(LDRReading);
delay(250);
}

Open the Arduino serial monitor and get values of reading in the room, in the dark and sunlight etc. Now, this is our final code for the thing we need :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int sensorReading;
void setup()
{
Serial.begin(9600);
pinMode(13,OUTPUT);
}
void loop()
{
sensorReading=analogRead(0);
if (sensorReading<1000)
{
digitalWrite(13,LOW);
}
else digitalWrite(13,HIGH);
Serial.println(sensorReading);
delay(500);
}

I have set the (sensorReading<1000) based on my available light’s reading on the Arduino serial monitor. The mechanism how the values are being printed is described in Arduino Analog vs digital pin.

So, for your need, (sensorReading<1000) may be lower or higher than 1000. Secondly, you can add multiple LEDs by simple modification.

In real life, we need this action for electric lights. We will need to use an Arduino relay module in place of the LED. There is no need for the extra sketch.

 

Proof of Concept

 

After following this tutorial, you will have a project in hand which will behave exactly like this video:

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Arduino Light Sensor: Circuit and Code

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • WordPress & PHP : Different AdSense Units on Mobile Devices

    Here is How To Serve Different AdSense Units on Mobile Devices on WordPress With PHP. WordPress Has Function Which Can Be Used In Free Way.

  • How to Control Multiple Relays With Single Arduino ESP32?

    Before How to Control Multiple Relays With Single Arduino ESP32 Testing, You Need to Learn How to Create Multiple MQTT Channels & Fetch Data.

  • Arduino With DHT 11 Sensor and Arduino Online IDE : Basic IoT

    Arduino With DHT 11 Sensor and Arduino Online IDE is Example of Basic IoT Which Needs No Special Hardware But Arduino, DHT11, Internet Connection & Web Browser.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

vpsdime

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Cloud-Powered Play: How Streaming Tech is Reshaping Online GamesSeptember 3, 2025
  • How to Use Transcribed Texts for MarketingAugust 14, 2025
  • nRF7002 DK vs ESP32 – A Technical Comparison for Wireless IoT DesignJune 18, 2025
  • Principles of Non-Invasive Blood Glucose Measurement By Near Infrared (NIR)June 11, 2025
  • Continuous Non-Invasive Blood Glucose Measurements: Present Situation (May 2025)May 23, 2025
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2026 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy