Introduction: Working With Sensors : Working With LDR
Step 1: Materials Required
Gather these materials and follow on =>
Step 2: Working Principle:
Light Dependant resistors as its name suggests is simply a resistor. However, there’s a catch. The LDR’s resistance changes with light. Yes, you heard it right… As the intensity of the light falling on the HEAD (the round upper part with wiggly structure) increases, the resistance of the LDR decreases. At absoulute darkness the value of resistance is very high. If you are interested, the LDRs are generally made of Cadmium Sulphide. [Who cares?]
The LDR is a passive component. But, we want voltage.[Hmm. How could we do that?] Remember, what you learnt in school. A Voltage Divider Circuit.
Step 3: Schematics and Circuit:
I know that you are smart enough to understand the above schematics. I assume some of you have even started wiring [That’s the spirit guys!!]. Anyways for some of you, here’s the text verison of the circuit:
One of the terminals of the LDR is connected to the +5V supply from the Arduino. Then the other terminal is connected to the Resistor R1. The other end of R1 is connected to the ground. From the point where the two terminals of LDR and R1 are connected; connect a wire to the Analog Input Pin 5 of Arduino (A5). Thats it on the hardware. Please note in the circuit that, the input to Arduino is an analog input measuring the value of voltage across R1.
Step 4: The Code:
he code for this project is simple and easy. Basically, we just read the analog input from the pin A5. Then we compare the value with certain threshold. If the value is below threshold, i.e. it is dark then we turn on the LED at pin 13 else we turn it off. The code can be downloaded off Github at:
https://github.com/mks2064/Arduino-and-Sensors/tre...
Ok, that should suffice your quest for learning on interfacing LDRs with Arduino.
Coming Next : Interfacing with Ultrasonic Sensor – HCSR04