The Light Dependent Resistor (LDR) module is a photosensitive device that is widely used in various light-sensing applications. The resistance of the LDR decreases with increasing light intensity, making it an essential component for projects that require light detection, such as automatic night lights, alarm systems, and environmental monitoring.
Pin Number | Description | Notes |
---|---|---|
1 | VCC (Power) | Connect to 3.3V or 5V supply |
2 | Signal Output | Analog voltage related to light |
3 | Ground (GND) | Connect to system ground |
// Define the LDR pin
const int ldrPin = A0;
void setup() {
// Initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
void loop() {
// Read the input on analog pin 0:
int sensorValue = analogRead(ldrPin);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1023.0);
// Print out the value you read:
Serial.println(voltage);
delay(1000); // Delay in between reads for stability
}
Q: Can I use the LDR module with a 3.3V system? A: Yes, the LDR module can be used with both 3.3V and 5V systems.
Q: What is the sensitivity range of the LDR module? A: The LDR module is most sensitive to light around 540 nm, which is in the visible light spectrum.
Q: How do I calibrate the LDR module for accurate light measurements? A: Calibration involves recording the LDR response at known light intensities and creating a reference curve or table to interpret future readings accurately.
This documentation provides a comprehensive guide to using the LDR module in electronic projects. For further assistance, consult the manufacturer's datasheet or contact technical support.