Introduction
This tutorial demonstrates how to measure ambient light intensity using an LDR (Light Dependent Resistor) sensor and Arduino. You’ll learn how to connect and program the components to read light intensity data.
Required Components
- 1 x Light Dependent Resistor (LDR)
- 1 x 10k-ohm resistor
- 1 x Arduino board
- Jumper wires
- Breadboard
Wiring Instructions
Follow these steps to set up the circuit for measuring light intensity with an LDR:
- Place the LDR on the breadboard.
- Connect one leg of the LDR to the 5V pin on the Arduino using a jumper wire.
- Connect the other leg of the LDR to the A0 analog input pin on the Arduino.
- Insert a 10k-ohm resistor onto the breadboard:
- Connect one end of the resistor to the same leg of the LDR that connects to A0.
- Connect the other end of the resistor to the GND pin on the Arduino.
- Ensure all connections are secure before proceeding to code the Arduino.
This wiring forms a voltage divider circuit, which is essential for reading the light intensity as an analog signal.
Arduino Code
#include
const int ldrPin = A0; // Analog pin connected to the LDR
void setup() {
Serial.begin(9600);
}
void loop() {
int lightIntensity = analogRead(ldrPin);
Serial.print("Light Intensity: ");
Serial.println(lightIntensity);
delay(500);
}
Applications
- Ambient light monitoring
- Automated lighting systems
- Light-sensitive alarms
Conclusion
By using this setup, you can measure and monitor light intensity for various projects. Experiment with using the light intensity data to control LEDs or send notifications!