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

Arduino UNO-Based Light-Sensitive LED Controller

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Light-Sensitive LED Controller

Circuit Documentation

Summary

This circuit is designed to detect light levels using a photodiode and respond by lighting up an LED if the light level falls below a certain threshold. The Arduino UNO microcontroller reads the voltage from the photodiode connected to its analog input pin A0. If the light level is below the threshold value of 200, the microcontroller activates an LED connected to its digital pin D3. The photodiode is powered by the Arduino's 5V output, and the LED is connected through a 220 Ohm resistor to ground.

Component List

Arduino UNO

Photodiode

Resistor (560 Ohms)

LED: Two Pin (red)

Resistor (220 Ohms)

Wiring Details

Arduino UNO

Photodiode

Resistor (560 Ohms)

LED: Two Pin (red)

Resistor (220 Ohms)

Documented Code

/*
 * This Arduino sketch reads the voltage from a photodiode connected to A0.
 * If the light level is below a threshold (200), it lights up an LED connected
 * to digital pin D3. The photodiode is powered by the 5V pin and the LED is
 * connected through a 220 Ohm resistor to ground.
 */

const int photoPin = A0; // Photodiode connected to analog pin A0
const int ledPin = 3;    // LED connected to digital pin D3
const int threshold = 200; // Light level threshold

void setup() {
  pinMode(ledPin, OUTPUT); // Set the LED pin as an output
  pinMode(photoPin, INPUT); // Set the photodiode pin as an input
}

void loop() {
  int lightLevel = analogRead(photoPin); // Read the light level
  if (lightLevel < threshold) {
    digitalWrite(ledPin, HIGH); // Turn on the LED
  } else {
    digitalWrite(ledPin, LOW);  // Turn off the LED
  }
  delay(100); // Small delay to stabilize the reading
}

The code is written for the Arduino UNO and is saved with the filename sketch.ino. It initializes the pins, reads the light level from the photodiode, compares it to a predefined threshold, and controls the LED accordingly.