LDR Sensor Tutorial

Measure Light Intensity with an LDR

Introduction

This tutorial demonstrates how to measure ambient light intensity using an LDR (Light Dependent Resistor) sensor and Arduino. You’ll learn how to connect and program the components to read light intensity data.

Required Components

Wiring Instructions

Follow these steps to set up the circuit for measuring light intensity with an LDR:

  1. Place the LDR on the breadboard.
  2. Connect one leg of the LDR to the 5V pin on the Arduino using a jumper wire.
  3. Connect the other leg of the LDR to the A0 analog input pin on the Arduino.
  4. Insert a 10k-ohm resistor onto the breadboard:
    • Connect one end of the resistor to the same leg of the LDR that connects to A0.
    • Connect the other end of the resistor to the GND pin on the Arduino.
  5. Ensure all connections are secure before proceeding to code the Arduino.

This wiring forms a voltage divider circuit, which is essential for reading the light intensity as an analog signal.

Arduino Code


#include 

const int ldrPin = A0;  // Analog pin connected to the LDR

void setup() {
    Serial.begin(9600);
}

void loop() {
    int lightIntensity = analogRead(ldrPin);
    Serial.print("Light Intensity: ");
    Serial.println(lightIntensity);
    delay(500);
}
            

Applications

Conclusion

By using this setup, you can measure and monitor light intensity for various projects. Experiment with using the light intensity data to control LEDs or send notifications!