In this post I am going to share how I found out that LEDs can sense Light. I know it sounds strange but it actually is true. I came to know about it as I was experimenting with arduino and sensors. I knew that IR LEDs can be used to sense IR light when used in reverse biased. So I tried using a normal LED to measure light and it worked !
I know it is not as sensitive as the LDRs and Photodiodes but still it is fun to try it out and we get to learn something which is never bad...
I have also made a light sensitive switch using this LED as sensor.
Making Connections :-- First place the LED (Sensor) in the breadboard.
Note:- LED works different in Forward and Reverse bias. In Forward biased mode i.e. Anode to pin A0 and Cathode to GND. the LED gives High values in Light and Low values in Dark. and vice versa in Reverse bias.
- Once the LED is placed in breadboard, Connect its one pin to A0 (analog pin) of Arduino. and connect its other pin to GND pin of Arduino.
- Now place another LED on breadboard and connect a 220 ohm resistor to its Anode. Connect a wire from the resistor to pin 13 on Arduino (digital pin). Connect the Cathode of LED to GND of Arduino.
(The sensor LED seems black but I have just wrapped black tape around it)When all the connections are done, next step is to upload the code.
Writing and Uploading Code :-For uploading code in Arduino we need an IDE, Arduino has its own free IDE you can visit Arduino.cc to download it.
Once You have set up the arduino IDE you can start writing code. refer the code given below to make the Arduino sensor :
I have uploaded two codes one for sensing the Light, second to make a light dependent switch using the LED as sensor. In the second code you will find a conditional statement " if( value > 100)" here the value 100 is set because my led works on that value, I have noticed different LEDs have different sensitivity levels so before making the switch circuit you will have to note the values of the LED in light and in dark. You can see the results in Serial Monitor. Refer the picture above to start serial monitor.
- First open the first code and upload the code to arduino.
- now open Serial monitor and note the values in dark and value after light is applied. these values can be used to trigger the switch.
eg: If in dark the value is 100-150 and in light it is 50-100. then the LED on pin 13 can be turned on by editing the if statement as :
if(value > 100 )
{
digitalWrite(led,HIGH);
}
now the LED will turn on when in Dark and if the greater than ">" is replaced with less than "<" then the LED will turn on in light.
That's all.
Hope you like the project.
Check out the video :-
Comments