A photocell, or light-dependent resistor (LDR), is a sensor that varies its resistance in response to light intensity. As the light falling on the LDR increases, its resistance decreases, and vice versa. This characteristic makes photocells ideal for creating light-sensitive circuits, which are widely used in applications such as automatic night lights, outdoor clocks, and security devices.
Photocells are two-terminal devices. The terminals can be connected in any orientation.
Pin | Description |
---|---|
1 | Terminal A |
2 | Terminal B |
// Define the LDR pin
const int ldrPin = A0;
void setup() {
// Begin serial communication at 9600 baud rate
Serial.begin(9600);
}
void loop() {
// Read the value from the LDR
int ldrValue = analogRead(ldrPin);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V)
float voltage = ldrValue * (5.0 / 1023.0);
// Print out the value you read
Serial.println(voltage);
// Delay for a bit to avoid spamming the serial output
delay(500);
}
Q: Can I use the LDR to measure specific light wavelengths? A: LDRs are generally sensitive to a broad range of visible light, not specific wavelengths.
Q: How do I increase the sensitivity of the LDR circuit? A: Adjust the value of the resistor in the voltage divider to change the sensitivity.
Q: What is the lifespan of an LDR? A: LDRs can last many years, but their performance may degrade with prolonged exposure to high-intensity light.
Q: Can an LDR be used outdoors? A: Yes, but it should be protected from direct exposure to elements like water and extreme temperatures.