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

Arduino UNO Light-Dependent LED Control System

View and Edit Project In Cirkit DesignerImage of Arduino UNO Light-Dependent LED Control System

Circuit Documentation

Summary

This circuit is designed to control 10 yellow LEDs based on the light intensity measured by a Light Dependent Resistor (LDR). The LDR is connected to the analog input A0 of an Arduino UNO, and the LEDs are connected to digital pins D2 through D11. The brightness of the LEDs is adjusted according to the light intensity detected by the LDR.

Component List

  1. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. LED: Two Pin (yellow)

    • Description: A yellow LED with two pins: anode and cathode.
    • Pins: cathode, anode
  3. Resistor

    • Description: A resistor with a resistance of 330 Ohms.
    • Pins: pin1, pin2
    • Properties:
      • Resistance: 330 Ohms
  4. Photocell (LDR)

    • Description: A Light Dependent Resistor (LDR) that changes its resistance based on the light intensity.
    • Pins: pin 0, pin 1

Wiring Details

Arduino UNO

LED: Two Pin (yellow)

Resistor

Photocell (LDR)

Code Documentation

/*
 * This Arduino sketch controls 10 yellow LEDs based on the light intensity
 * measured by a Light Dependent Resistor (LDR). The LDR is connected to the
 * analog input A0, and the LEDs are connected to digital pins D2 through D11.
 */

const int ldrPin = A0; // LDR connected to analog pin A0
const int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; // LED pins

void setup() {
  // Initialize LED pins as outputs
  for (int i = 0; i < 10; i++) {
    pinMode(ledPins[i], OUTPUT);
  }
}

void loop() {
  int ldrValue = analogRead(ldrPin); // Read the LDR value
  int brightness = map(ldrValue, 0, 1023, 0, 255); // Map LDR value to brightness

  // Set the brightness of each LED
  for (int i = 0; i < 10; i++) {
    analogWrite(ledPins[i], brightness);
  }

  delay(100); // Small delay to stabilize readings
}

This code reads the value from the LDR connected to analog pin A0, maps the value to a brightness level, and sets the brightness of the 10 LEDs connected to digital pins D2 through D11 accordingly. The setup function initializes the LED pins as outputs, and the loop function continuously reads the LDR value, maps it to a brightness level, and updates the LEDs.