Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Light-Activated LED with LDR Sensor

View and Edit Project In Cirkit DesignerImage of Arduino UNO Light-Activated LED with LDR Sensor

Circuit Documentation

Summary

This circuit is designed to control an LED based on the ambient light level detected by an LDR (Light Dependent Resistor) module. The circuit uses an Arduino UNO to read the LDR values and control the LED accordingly. When the ambient light level is below a certain threshold, the LED will turn on, and it will turn off when the light level is above the threshold.

Component List

  1. LED: Two Pin (yellow)

    • Description: A yellow LED with two pins: anode and cathode.
    • Purpose: Indicates the light level by turning on or off.
  2. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P.
    • Purpose: Reads the LDR values and controls the LED.
  3. Module LDR

    • Description: A Light Dependent Resistor module with four pins: VCC, GND, DO, and AO.
    • Purpose: Measures the ambient light level.
  4. Resistor

    • Description: A resistor with a resistance of 330 Ohms.
    • Purpose: Limits the current flowing through the LED to prevent damage.

Wiring Details

LED: Two Pin (yellow)

Arduino UNO

Module LDR

Resistor

Code Documentation

const int LDRPin = A0; // Analog pin for LDR
const int LEDPin = 9;  // Digital pin for LED

void setup() {
  pinMode(LEDPin, OUTPUT); // Set LED pin as output
  Serial.begin(9600);      // Begin Serial Communication
}

void loop() {
  int lightValue = analogRead(LDRPin); // Read LDR value
  Serial.println(lightValue);          // Print LDR value for calibration

  if (lightValue < 600) {
    digitalWrite(LEDPin, HIGH); // Turn ON LED in darkness
  } else {
    digitalWrite(LEDPin, LOW);  // Turn OFF LED in light
  }
  delay(500); // Small delay for stability
}

Code Explanation