Pages: [1] 2   Go Down
Author Topic: LEDs as Photo-diodes  (Read 2075 times)
0 Members and 1 Guest are viewing this topic.
Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1001
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I saw a few videos around the internet lately that were pretty nifty.  Using an led as a photo-diode.  I saw a thread and there was a link to the arduinos photo-diode tutorial although it didn't work for me for some reason.

Can anybody offer an awesome explanation or link me to a tutorial?

Logged

Accelerate to 88 miles per hour.

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1730
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

They almost certainly weren't LEDs. The will have been phototransistors in an LED shape package.

The two behave totally differently as they use different sorts of semiconductor junction.
Logged

~Tom~

Dallas, Texas
Offline Offline
God Member
*****
Karma: 31
Posts: 887
Old, decrepit curmugeon
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Do a search for Forest M. Mims.

He has published a number of articles on using standard leds as photo diodes.  I have used a reverse biased green led connected to an osciliscope to measure the duration of a photographic flash unit like this


   9V
   ^
   |
 LED (reverse biased)
   |
   +--- Oscilliscope
   |
  1K resistor
   |
 Gnd
Logged

New true random number library available at: http://code.google.com/p/avr-hardware-random-number-generation/

Current version 1.0.1

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34726
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
They almost certainly weren't LEDs.
They we're you know.
I have a page on it, in the workshop section
http://www.thebox.myzen.co.uk/Workshop/LED_Sensing.html
« Last Edit: August 03, 2012, 12:59:53 am by Grumpy_Mike » Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1730
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I stand corrected. Finally a use for reverse biased LEDs!
Logged

~Tom~

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Reversed biased leds do work as photo-diodes. Find below code that provides a solution to controlling leds from a led light detector. This can be a multilevel dark detector too!

Code:
/* LED_LIGHT_CONTROL_IBLE
 * -----------------------
 * This program uses separate led's for light and sensing light.
 * Works with room ambient or daylight.
 * LED light sensing modified from Hunter's Instructible. Acheives sharp
 * cut off and on according to "int light = X". Could also fade lights
 * in/out on analog pins.
 *
 * Hunter Carlson
 * June 9 2009
 * Edits added Nov. 9, 2012 -fabelizer
 *
 * Requires at least 2 (or 3 or more) LEDs, one to analog pins 4 & 5, other
 * to D8 & GND through a resistor. I used a water clear superbright
 * red led for the sensor led, white for led1.
 * See comments below for polarities and connections.
 */

int sense01 = 5;        // sensing LED anode connected to analog pin5
int sense02 = 4;        // sensing LED cathode connected to analog pin4
                        // you can switch out different leds on these
                        // pins to see which works best. Run the
                        // serial monitor and watch the changes.
                                               
int LED01 = 8;          // LED anode to dig pin8, cathode to 220R
                        // 220R to GND.
int LED02 = 9;          // LED anode to dig pin9, cathode to 220R
                        // 220R to GND.
                       
int val01 = 0;          // variable to store the value read from sense01
int val02 = 0;          // variable to store the value read from sense02

int light1 = 110;       // set light threshold for led1
int light2 = 80;        // set light threshold for led2

void setup()
{
  Serial.begin(9600);        // setup serial (comment out to save memory)
  pinMode(LED01, OUTPUT);    // led1 pin set to output
  pinMode(LED02, OUTPUT);    // led2 pin set to output
}

void loop()
{
  val01 = analogRead(sense01);      // read sense01 led
  val02 = analogRead(sense02);      // read sense02 led
 
   //debug print
  Serial.print(val01              // comment this section out to save memory
  Serial.println(val01-val02);    // result is printed and compared with light1 or 2
  Serial.println();               // blank line between values
 
                                    // first led 'led1'
 if ((val01 - val02) >= light1) {   // check if light in area
      digitalWrite(LED01, LOW);     // if light enough, turn off led1
    } else {                     
      digitalWrite(LED01, HIGH);    // if dark enough, turn on led1
    }
   
                                    // second led 'led2'
 if ((val01 - val02) >= light2) {   // check if light in area
      digitalWrite(LED02, LOW);     // if light enough, turn off led2
    } else {                     
      digitalWrite(LED02, HIGH);    // if dark enough, turn on led2
    }
   
delay(100);                         // just to slow things down a bit

}

-fab
Logged

0
Offline Offline
Faraday Member
**
Karma: 24
Posts: 3501
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

My page offers explanations plus links to the original research: http://blog.blinkenlight.net/experiments/measurements/led-camera/

You do not even need to reverse bias them. No matter in which direction you bypass them.
The reverse bypassing is only needed if you do not have an ADC but only digital inputs. With ADC inputs you can measure and find out that they work as photodiodes no matter how you bypass them.
Logged

Check out my experiments http://blog.blinkenlight.net

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Folks at Mistubishi started this. Google their article.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26636
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Keywords are Mitsubishi and iDropper.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Eugene, Oregon
Offline Offline
Sr. Member
****
Karma: 9
Posts: 388
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Heres an example of somone using an arduino, and LEDs as both lights, and sensors. The top corner LEDs are also sensors to control what the cube does.

https://www.youtube.com/watch?v=m3U-7cyNmFg

There is an instructible about it, and i think he did the whole 4x4x4 cube with no ICs (drivers or shift registers)
Logged


Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The approach proposed in the mistubishi paper is good for higher power led or at low lighting levels.

The charge transfer approach is good for regulator led or at high lighting levels. It is also simpler to implement and faster to run.
Logged

0
Offline Offline
Full Member
***
Karma: 4
Posts: 218
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just some links that seem pertinent


http://www.merl.com/areas/LEDcomm/  Original Mitsubishi article
http://arduino.cc/forum/index.php/topic,128556.0.html Thread I started ,didn't see this one

I could not find this ?
Quote
Hunter's Instructible. Acheives sharp


http://www.instructables.com/id/Bi-directional-LED-Sensing-Try-out/  Practical board and code setup
My code to play with this concept
Code:
const int led1 = A2;
const int led2 = A1;

int value1, value2;
int threshold1 = 120;
int threshold2 = 120;

void setup(){
  Serial.begin(9600);
  pinMode(led1,INPUT);
  pinMode(led2,INPUT);
  }

void loop(){
  value1 = analogRead(A2);
  value2 = analogRead(A1);
  if(value1 >= threshold1){
    Serial.print("Value 1 : ");
    Serial.println(value1);
    out(led1,led2,threshold1);
    pinMode(led2,INPUT);
  
  }
  else if(value2 >= threshold2){
    Serial.print("Value 2 : ");
    Serial.println(value2);
  
    out(led2,led1,threshold2);
    pinMode(led1,INPUT);
  
  }
}

void out(int a, int b, int threshold){
  pinMode(b,OUTPUT);
  //if (a==led2)
  //delay(30);
  //else
  //delay(60);
  int value = analogRead(a);
    if(value >= threshold){
      analogWrite(b,value);
         }
    else{analogWrite(b,0);    }
     Serial.print("Value Following: ");
    Serial.println(value2);
  }

« Last Edit: November 13, 2012, 04:05:36 pm by april » Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Not sure what your code is trying do but this is what I would try:

Code:
//read reverse of a led's cathode
unsigned short led_adc(unsigned char pin) {
  //energize the pin
  digitalWrite(pin, HIGH);
  pinMode(pin, OUTPUT);

  //put some delays here
  NOP(); NOP(); NOP(); NOP(); NOP();

  //adc the pin
  pinMode(pin, INPUT);

  return analogRead(pin);
}

void loop(){
  //read A1
  Serial.print("Value 1 : ");
  Serial.println(led_adc(A1));
  //out(led1,led2,threshold1);
  //pinMode(led2,INPUT);
   
  //read A2
  Serial.print("Value 2 : ");
  Serial.println(led_adc(A2));
}

led_adc() energies the led capacitance and then adc the charge transfer. For high led capacitance, you should read a voltage very close to 1023; Lower led capacitance results in lower reading - more charges are transfered to Chold -> lower voltage across the led capacitor.
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The charger transfer approach can be used as a way to measure small capacitance.
Logged

0
Offline Offline
Full Member
***
Karma: 4
Posts: 218
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Not sure what your code is trying do but this is what I would try:If you build it you will see an LED recognises the flash of another LED by flashing itself in the same sequence . So if I press the button on LED1 ,on and off the LED2 flashes on and off
  //put some delays here
  NOP(); NOP(); NOP(); NOP(); NOP();This does not compile. When I add in what is required to compile it with a delay(400) I get alternating  flashing LED's . So that's a bit vague , What are you trying to do and maybe I can help you
led_adc() energies the led capacitance and then adc the charge transfer. For high led capacitance, you should read a voltage very close to 1023; Lower led capacitance results in lower reading - more charges are transfered to Chold -> lower voltage across the led capacitor.


Code:
//read reverse of a led's cathode
#define NOP() asm("nop") //waste a tick
void setup(){
Serial.begin(9600);}
unsigned short led_adc(unsigned char pin) {
  //energize the pin
  digitalWrite(pin, HIGH);
  pinMode(pin, OUTPUT);

  //put some delays here
  NOP(); NOP(); NOP(); NOP(); NOP();
delay(400);
  //adc the pin
  pinMode(pin, INPUT);

  return analogRead(pin);
}

void loop(){
  //read A1
  Serial.print("Value 1 : ");
  Serial.println(led_adc(A1));
  //out(led1,led2,threshold1);
  //pinMode(led2,INPUT);
  
  //read A2
  Serial.print("Value 2 : ");
  Serial.println(led_adc(A2));
}
« Last Edit: November 14, 2012, 03:24:10 pm by april » Logged

Pages: [1] 2   Go Up
Jump to: