Wisconsin
Offline
God Member
Karma: 4
Posts: 994
I LOVE THIS STUFF!!!!
|
 |
« on: August 02, 2012, 11:28:12 am » |
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
God Member
Karma: 35
Posts: 987
Once the magic blue smoke is released, it won't go back in!
|
 |
« Reply #1 on: August 02, 2012, 12:05:15 pm » |
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
God Member
Karma: 1
Posts: 689
Old, decrepit curmugeon
|
 |
« Reply #2 on: August 02, 2012, 01:02:53 pm » |
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
|
|
|
|
|
Manchester (England England)
Online
Brattain Member
Karma: 277
Posts: 25556
Solder is electric glue
|
 |
« Reply #3 on: August 02, 2012, 05:30:56 pm » |
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
God Member
Karma: 35
Posts: 987
Once the magic blue smoke is released, it won't go back in!
|
 |
« Reply #4 on: August 02, 2012, 07:20:56 pm » |
I stand corrected. Finally a use for reverse biased LEDs!
|
|
|
|
|
Logged
|
~Tom~
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 6
|
 |
« Reply #5 on: November 10, 2012, 11:10:30 pm » |
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! /* 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
Online
Faraday Member
Karma: 16
Posts: 3196
20 LEDs are enough
|
 |
« Reply #6 on: November 11, 2012, 05:04:21 am » |
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
|
|
|
|
|
Offline
Edison Member
Karma: 114
Posts: 2205
|
 |
« Reply #7 on: November 11, 2012, 07:57:04 am » |
Folks at Mistubishi started this. Google their article.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #8 on: November 11, 2012, 09:16:52 am » |
Keywords are Mitsubishi and iDropper.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Eugene, Oregon
Offline
Sr. Member
Karma: 8
Posts: 387
|
 |
« Reply #9 on: November 11, 2012, 01:00:32 pm » |
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-7cyNmFgThere is an instructible about it, and i think he did the whole 4x4x4 cube with no ICs (drivers or shift registers)
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 114
Posts: 2205
|
 |
« Reply #10 on: November 11, 2012, 04:08:29 pm » |
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
Full Member
Karma: 3
Posts: 218
Arduino rocks
|
 |
« Reply #11 on: November 13, 2012, 03:50:53 pm » |
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 ? 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 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
Edison Member
Karma: 114
Posts: 2205
|
 |
« Reply #12 on: November 13, 2012, 04:28:00 pm » |
Not sure what your code is trying do but this is what I would try: //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
Edison Member
Karma: 114
Posts: 2205
|
 |
« Reply #13 on: November 13, 2012, 04:28:43 pm » |
The charger transfer approach can be used as a way to measure small capacitance.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 3
Posts: 218
Arduino rocks
|
 |
« Reply #14 on: November 14, 2012, 01:41:38 am » |
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.
//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
|
|
|
|
|
|