Using Photo Resistor and LED Lights with an Ambient Light Sensor

13 May 2023 Balmiki Mandal 0 µC - µP

Ambient Light Sensor Using Photo Resistor and LED Lights

Photo resistors, also known as light dependent resistors (LDR), are components that vary their resistance when exposed to varying levels of light. LED lights, or light emitting diodes, are a type of low voltage light source that can be used to back-light a photo resistor. This combination of photo resistor and LED lights creates a great way to detect ambient light levels.

How It Works

The photo resistor is connected to an LED light and then connected in a voltage divider circuit with a fixed resistor. This means that, as the ambient light level increases, the resistance of the photo resistor decreases. Thus, when the voltage is read across the LED, it will be decreased as the light level increases.

By measuring the voltage across the LED, it is possible to detect changes in ambient light levels. The LED will provide a reference voltage, to which the voltage from the photo resistor can be compared against. If the voltage from the photo resistor is greater than the reference voltage, it indicates a lower ambient light level. Conversely, if the voltage from the photo resistor is lower than the reference voltage, it indicates a higher ambient light level.

Applications

Ambient light sensors using photo resistors and LEDs can be used in a variety of applications such as detecting daylight hours, switching on and off lights based on the amount of light present, and controlling the brightness of back-lit displays.

It is also possible to use these sensors as part of a home security system, allowing lights or camera’s to be automatically switched on when it gets dark. The sensors could also be used to automatically dim or switch off lights after a set period of time.

Required Materials

  • Arduino board
  • Breadboard
  • Jumper wires
  • 10K Ohm resistor
  • 220 Ohm resistor
  • Photoresistor
  • LED

    Circuit Diagram

    Connect the photoresistor to the breadboard by connecting one leg to the 5V pin and the other leg to the analog input pin A0. Connect a 10K Ohm resistor between the same analog input pin and the ground. Connect the LED to the breadboard with its cathode (the shorter leg) connected to a 220 Ohm resistor, which is connected to digital pin 9 of the Arduino board. The anode (the longer leg) of the LED should be connected to the 5V pin of the Arduino board.

const int ledPin = 9; // LED connected to digital pin 9
const int photoPin = A0; // Photoresistor connected to analog input A0

void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int photoValue = analogRead(photoPin);
  Serial.println(photoValue);
  if (photoValue < 500) {
    digitalWrite(ledPin, HIGH);
  } else {
    digitalWrite(ledPin, LOW);
  }
  delay(10);
}

How It Works

The photoresistor is essentially a variable resistor that changes its resistance based on the amount of light it receives. As the light level increases, the resistance of the photoresistor decreases, and vice versa. By connecting the photoresistor to an analog input pin on the Arduino board, we can measure its resistance using the analogRead() function.

The if statement in the code checks the value of the photoresistor's resistance. If the resistance is low (indicating a bright light level), the LED is turned off by setting the output of digital pin 9 to LOW. If the resistance is high (indicating a dark light level), the LED is turned on by setting the output of digital pin 9 to HIGH.

The delay() function is included to prevent rapid fluctuations in the LED brightness caused by the photoresistor's resistance changing too quickly.

In summary, an ambient light sensor using a photoresistor and LED lights is a simple and effective way to control the brightness of an LED based on the surrounding light level. By measuring the resistance of the photoresistor and adjusting the LED output accordingly, we can create an automatic lighting system that responds to changes in ambient light.

Conclusion

Photo resistors combined with LED lights offer a great way to detect ambient light levels. By measuring the voltage across the LED, it is possible to accurately determine light levels, allowing for various applications such as detecting daylight hours, controlling back-light displays, and automating home security systems.

BY: Balmiki Mandal

Related Blogs

Post Comments.

Login to Post a Comment

No comments yet, Be the first to comment.