From the past - Use an LED as a light sensor

I am clearing out my old files. Most 25 year old projects are no longer relevant, technology marches on and old parts disappear. I did find this in the "stupid LED tricks" file and thought it might be interesting. It was popular 25 years ago but I haven't seen it lately.

It uses the LED junction capacitance and photoelectric effect to measure light intensity. The LED is reverse biased which pulls the charge carriers away from the junction into the bulk P and N materials. The cathode is then grounded and the anode voltage monitored. As the charges drift back to the junction the anode voltage drops and as it passes the digital threshold voltage the reading changes from 1 to 0. If the junction is illuminated with high enough energy light (more on that later) electrons will be released which will speed up the recovery time.

The Led is then forward biased (normal use) for a time based on the recovery time. In this case longer for less light.

Due to the differences in LEDs and digital thresholds it is probably not useful beyond a demo. It may be an interesting middle school science project. Trying different LED colors for the sensor and source. Hint: a red LED illuminating a blue one won't do much. The opposite will work. Why?

Spoiler alert: The illuminating light must be the same or shorter wavelength (higher energy) than the color emitted by the LED. Search photoelectric effect. Einstein's only Nobel prize was for explaining it.

/*
 * Led Sense
 *
 * Use Led as light detector 
 * Reverse bias led which will charge the junction capacitance.
 * Then determine time for recovery from reverse bias.
 * This will be the time for carrier recombination which is
 * light dependent - more light will speed recombination
 * 
 * Use the result to light the LED for a time based on the light level
 * 
 */

// connect an LED with 1K series resistor across these pins. The resistor can be on 
// either the anode or cathode side.
const int ledCathode = 6; 
const int ledAnode = 7; 

void setup()                    // run once, when the sketch starts
{
  pinMode(ledAnode, OUTPUT);  
  pinMode(ledCathode, OUTPUT);   
  Serial.begin(115200); 
}

void loop()                      // run over and over again
{
  unsigned long int startTime,recoverTime;
  
  // reverse bias the led
  digitalWrite(ledCathode, HIGH); 
  digitalWrite(ledAnode, LOW);   
  delay(200);                    // wait for charge time
  
  // Measure recovery time
  pinMode(ledCathode, INPUT);    // set to input
  digitalWrite(ledCathode, LOW); // ground reference
  startTime = micros();
  do ;
      // nothing
  while (digitalRead(ledCathode) == 1); // wait for charge to leak off
  recoverTime = micros() - startTime;  
  
  Serial.println(recoverTime);
  
  // turn led on based on light level
  pinMode(ledCathode, OUTPUT);     
  digitalWrite(ledCathode, LOW); // forward bias the led
  digitalWrite(ledAnode, HIGH);
  delay(recoverTime/50);         // on longer in dark - 50 is juat to adjust the time modify to suit
  digitalWrite(ledAnode, LOW);   // turn off Led
 
 // delay(1000);                   // waits for a second
}

OR you could cut the metal cap off an old transistor and use it as a light sensor.

No need to cut the top off one. You can buy photo transistors with transparent cases.

You can sand the black paint off the oc series...

This is the photovoltaic effect. Some cheap learning IR remote control devices use this effect so the same LED that is used to transmit IR signals is also used to receive any IR signals, at short range, when the device is in learning mode.

But some times when you did it turned out to be a blue colored substance that looked like silly putty, so it did not always work. The OC71 was the best for having a translucent jell in them. By these were PNP germanium transistors. I think they stopped making them way back in 1965 or there abouts.

I scavanged a few from old transistor radios. I think I still have 1 or two...

My first light sensor was made from selenium. I remember the the selenium rectifiers all had a heavy coat of paint to limit the photoelectric effect.