Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO Based Light Intensity Control System

Image of Arduino UNO Based Light Intensity Control System

Circuit Documentation

Summary of the Circuit

This circuit is designed around an Arduino UNO microcontroller, which serves as the central processing unit. The circuit includes two resistors, a photocell (Light Dependent Resistor, LDR), and a red LED. The Arduino UNO is programmed to read the analog voltage across the photocell, calculate the corresponding voltage, and then adjust the brightness of the LED based on the photocell's resistance, which changes with light intensity. The LED is driven by a PWM signal on pin D9 of the Arduino UNO.

Component List

Arduino UNO

  • Description: A microcontroller board based on the ATmega328P.
  • Purpose: Acts as the central controller for the circuit, reading sensor data and controlling the LED brightness.

Resistor (320 Ohms)

  • Description: A passive two-terminal electrical component that implements electrical resistance as a circuit element.
  • Purpose: Limits current to protect components and creates a voltage divider with the photocell.

Photocell (LDR)

  • Description: A light-dependent resistor whose resistance decreases with increasing incident light intensity.
  • Purpose: Senses the ambient light level to control the LED brightness.

LED: Two Pin (red)

  • Description: A red light-emitting diode.
  • Purpose: Provides a visual output that varies in brightness according to the photocell reading.

Wiring Details

Arduino UNO

  • Digital Pin 9: Connected to one end of a 320 Ohm resistor, the other end of which is connected to the anode of the red LED.
  • Ground (GND): Connected to the cathode of the red LED and one pin of the photocell (LDR).
  • 5V Pin: Connected to one end of a 320 Ohm resistor, the other end of which is connected to one pin of the photocell (LDR).
  • Analog Pin A0: Connected to the junction between the photocell (LDR) and a 320 Ohm resistor, forming a voltage divider.

Resistor (320 Ohms)

  • One Resistor: Connects the 5V supply to the photocell and Arduino UNO's Analog Pin A0.
  • Another Resistor: Connects the Arduino UNO's Digital Pin 9 to the anode of the red LED.

Photocell (LDR)

  • One Pin: Connected to the Ground (GND) of the Arduino UNO.
  • Another Pin: Connected to the 5V supply through a 320 Ohm resistor and to the Arduino UNO's Analog Pin A0.

LED: Two Pin (red)

  • Anode: Connected to Digital Pin 9 of the Arduino UNO through a 320 Ohm resistor.
  • Cathode: Connected to the Ground (GND) of the Arduino UNO.

Documented Code

void setup() {
  Serial.begin(9600);
  pinMode(9, OUTPUT);
  digitalWrite(9,HIGH);
  delay(1000);
  digitalWrite(9,LOW);
  delay(2000);
}

void loop() 
{
  int SensorVal = analogRead(A0);
  float voltage1 = (5.0 / 1023.0) * SensorVal;
  Serial.print("Voltage1=");
  Serial.println(voltage1);
  Serial.println(" ");
  float voltage2 = 255 * (voltage1 / 5);
  int i = voltage2;
  Serial.println(i);
  Serial.println(255 - i);
  analogWrite(9, 255 - i);
  delay(1000);
} 

File Name: sketch.ino

Description: The code initializes the serial communication and configures pin 9 as an output to drive the LED. In the loop, it reads the analog value from pin A0, converts it to a voltage, and then calculates a PWM value to adjust the LED brightness inversely proportional to the light level detected by the photocell. The serial monitor outputs the voltage and PWM values for debugging purposes.