Does an LED work as a light sensor? Short answer is yes. That's fairly well known, but I've never tried it myself, so here goes.
I'm going to use a couple of old high-brightness red LEDs. I don't know much about them other than that they are definitely high in brightness, have a narrow viewing angle, and the package is 'crystal clear'.
My light source is an Arduino flashing one of the LEDs five hundred times a second [if jancumps can do a 'blinky', so can I!]. I've got a 330R resistor for the current limiting, so the current will be around 10mA.
For the receiver I repurposed an old experiment, so not ideal but it will do for the blog. The board had an OP177 op amp on it. I've reworked it to be a simple transimpedance amplifier. It won't be particularly fast, but with a bit of luck it will be able to keep up with the Arduino.
The output of the reverse-biased LED will be a few uA at most [the current is proportional to the light and is what we are trying to detect].
Here's the circuit
and here it is on the bench
Most of the photo-current through the LED also flows through the 10M resistor. The op amp will adjust its output so that the connection between the LED and the resistor remains at 2.5V, to match the other input. So the voltage across the resistor will be 10V for each uA of current flow. With a more sophisticated circuit we could get that output voltage referenced to ground, either by working with dual-rail supplies or by following the transimpedance amplifier with a differential amplifier. In this case I'm going to cheat and clip the earth of the scope to the 2.5V being produced by the voltage reference. That's effectively the same potential as the LED/resistor node. I can do that because the bench supply output that's powering the board isn't tied to any outside voltage. [The reason for not attaching it to the node itself is because that would cause the op amp to oscillate (I tried it: it does).]
Here's what the oscilloscope sees:
The yellow trace is the op-amp output [relative to the 2.5V reference] and the blue trace shows the Arduino pin that's driving the LED. The output from the LED is only just up at the 1uA mark, and that's with a lot of light pouring in to it, but it does work (the op amp output is limiting at the top). I was worried that the 'dark' current (the basic leakage current of the diode) might be quite high, but you can see from this that it's actually fairly good and doesn't have any impact on the results.
The ramping of the output up and down comes from the charging of the capacitor across the feedback resistor.
Next, I tried increasing the distance between the LEDs by about a centimetre, like this
and that produced this trace
now the amplitude is lower (there's quite a lot of overshoot, but I'm going to ignore that).
OK, so what happens if I change the red LED on the UNO side for a green one, like this?
Does it still work?
And the answer is yes. The level is much lower, but then the green LED is dimmer anyway.
Having just invented the optocoupler, I'm going to stop there. As far as I can see, there isn't any real use of this - if you need an optocoupler, buy an optocoupler; don't try and make one out of a pair of LEDs - but it's quite fun to play with.
There's a further blog on the topc here: More on Using an LED as a Light Sensor
If you found this interesting and would like to see other blogs I've written, a list can be found here: jc2048 Blog Index