Introduction: The LDR (Light-Dependant Resistor) is a resistor type that varies your resistance value according to the light that converges over your surface. The Photoelectric Phenomenon, that makes the photoconduction in the LDR possible, was explained for the first time in 1905 by Albert Einstein. He shown that the light, converging over a metal-like surface, can be accepted as a stream of energetic particles called Photons and these particles do have electric charge.
What happens in a LDR is that the light that converges over his surface increases the conductibility of the material (or reduces the resistance). Thus, the electrons on the electric current that flows over the LDR terminals can move more easily.
→ One LDR (Light-Dependant Resistor);
→ One LED (Light Emissor Diode);
→ One 330 Ohm resistor;;
→ Protoboard;
→ Jumpers.
On a Protoboard, assemble the circuit below:
Where:
→ Red wires and black wires referes to VCC 5V and GND, respectively;
→ The Yellow wire connects the output voltage from the LDR, to be read by an ADC (in this case, A0);
→ The orange wire connects the LED resistor to the Digital Output (D7).
Upload the following code to Galileo, using the Arduino IDE or compiling directly from Linux terminal:
1. |
const int pinLDR = A0; |
To modify the led switching to ON when light focus over LDR surface (and keep it for 10s) you just have to change the void loop () to:
1. |
void loop () { |
igitalWrite(pinLed, LOW);
} else
{
digitalWrite(pinLed, HIGH);
delay (10000);
}
}
This method is widely used in parking lots and stairways.