Codey OnlineArduino & ESP32 component library › LDR Sensor Module
LDR Sensor Module
Sensors

LDR Sensor Module

An LDR (light dependent resistor) sensor module outputs an analog voltage that changes with ambient light intensity. Connect the module’s power (+) and ground (-) to your board, and read the light-dependent signal from the S analog pin using an Arduino/ESP32 analog input.

Width: 21.6 mm

Pinout — LDR Sensor Module

Pin Signal Description
S analog Signal
+ power VCC
- ground GND

Example wiring diagram — LDR Sensor Module

From To Wire
board:A0 x1:S green
board:5V x1:+ red
board:GND x1:- black

Example Arduino code — LDR Sensor Module

This example was written and compile-checked for the arduino-uno. Codey Online adapts it to any other supported board for you.

// Canonical beginner example for an LDR Sensor Module
// Reads the analog light level and prints it to Serial.

const int ldrPin = A0;

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ; // Needed for some boards; safe on Uno as well
  }

  Serial.println("LDR Sensor Module example");
  Serial.println("Reading analog light level from A0...");
}

void loop() {
  int lightValue = analogRead(ldrPin);

  Serial.print("Light level: ");
  Serial.print(lightValue);
  Serial.println(" / 1023");

  delay(500);
}

Related components

18650 Battery Shield with USB-C Charger and 5V Boost Converter

18650 Battery Shield with USB-C Charger and 5V Boost Converter

2.4 inch OLED Display I2C 3.3V

2.4 inch OLED Display I2C 3.3V

3.5 inch TFT LCD Shield

3.5 inch TFT LCD Shield

50kg Load Cell Weight Sensor

50kg Load Cell Weight Sensor

Build your Arduino or ESP32 project with AI

Describe what you want to build. Codey Online writes the code, draws the wiring diagram, compiles it and flashes your board straight from the browser.

Start for free