Project tutorial
LED as a Light Sensor

LED as a Light Sensor © CC BY-NC-SA

Use a normal LED to sense light.

  • 9,759 views
  • 9 comments
  • 23 respects

Components and supplies

About this project

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 :-

Code

led_sensor.inoArduino
Code to read the values from LED and display it on Serial Monitor.
/* To read values from led as a sensor. Upload the code in arduino. 
 * Connect the LED to pin A0 (analog pin) of arduino.
 * Connect second pin to GND.
 * Open serial monitor to see the values.
 *Code by Harsh Dethe.
*/

int sensor = A0;  // define analog pin A0. (input/sensor)

void setup()
{
  Serial.begin(9600); //sets serial communication between arduino and computer
  pinMode(sensor,INPUT); // sets analog pin A0 as input.
}

void loop()
{
  int value = analogRead(sensor); // sets variable "value" to store value of sensor.
  Serial.println(value); //prints values in serial monitor
  delay(500); //half a second delay
}
led_sensor_2.inoArduino
Code to use LED as a light sensor and control another LED.
/* To read values from led as a sensor. Upload the code in arduino. 
 * Connect the LED to pin A0 (analog pin) of arduino.
 * Connect second pin to GND.
 * Open serial monitor to see the values.
 * Code by Harsh Dethe.
*/

int sensor = A0;  // define analog pin A0. (input/sensor)
int led = 13; // define pin 13 for led (output)

void setup()
{
  Serial.begin(9600); //sets serial communication between arduino and computer
  pinMode(sensor,INPUT); // sets analog pin A0 as input.
  pinMode(led,OUTPUT); //sets pin 13 as output.
}

void loop()
{
  int value = analogRead(sensor); // sets variable "value" to store value of sensor.
  Serial.println(value); //prints values in serial monitor
  delay(500); //half a second delay
  
  if(value > 100) //condition
  {
    digitalWrite(led,HIGH); //turns LED on.
  }
  else
  {
    digitalWrite(led,LOW); //turns LED off
  }
}

Comments

Similar projects you might like

Ambient Light Sensor Using Photo Resistor and LED Lights!

Project tutorial by DCamino

  • 7,885 views
  • 5 comments
  • 21 respects

Controlling LED light intensity using smartphone light senso

Project tutorial by Nikola Travis

  • 2,736 views
  • 0 comments
  • 1 respect

LED Emergency Lights using WS2812 RGB LED Module

Project tutorial by bigboystoys13

  • 14,022 views
  • 7 comments
  • 33 respects

Touch LED Table - Retrogaming And Ambiant Light

Project tutorial by Arbalet Project

  • 10,899 views
  • 1 comment
  • 47 respects

LED Controlled by 3D Gesture Sensor

Project tutorial by HomeMadeGarbage

  • 7,559 views
  • 0 comments
  • 21 respects

LED Matrix + Motion Sensor Door Display [Arduino Holiday]

Project tutorial by HeathenHacks

  • 4,775 views
  • 4 comments
  • 23 respects
Add projectSign up / Login