
How to use LEDs to detect light - chrisbennet
https://makezine.com/projects/make-36-boards/how-to-use-leds-to-detect-light/
======
jotux
I designed motion detectors for a couple years and once spent a few weeks
researching the use of LEDs as light detectors. What I found was the
wavelength each LED could detect and the sensitivity was inconsistent from
LED-to-LED and inconsistent across LED batches. We were producing 50k-1M units
per year so those findings made using the LED as a sensor a deal breaker and
we eventually just added a $0.12 photo-sensor to the boards to detect light.

All of that said, I designed a few demos (using the LED on the motion detector
as a light sensor) that were pretty cool:

\- I connected the amplified LED input on a motion detector to the
microcontroller and sampled the LED in between PWM cycles (we PWMed the LED to
save power). Even when the LED was on you could shine a flashlight at the
motion detector light-pipe and trigger events or a test mode.

\- On a motion detector that had a bi-color LED (red/green) in the same SMT
package I connected the amplified LED input from one LED to the
microcontroller and pulsed the other LED at a non-visible rate. If you placed
your finger on the light pipe it would reflect the light from the pulsing LED
to the other LED and you could detect when someone touched the light-pipe.

\- A motion detector that could receive serial data over the LED to configure
parameters.

~~~
sofon
wow that's neat! sampling between PWM cycles is a cool idea.

I'd guess the issue is that the required parameters are not well controlled in
the fabrication of most LEDs. Possibly LEDs not used as indicators, with a
tighter wavelength output... most likely this would remove any cost advantage
however.

Fascinating stuff!

~~~
jotux
Ya, they're not designed as detectors so there's no control over the
parameters that determine how good they are as detectors. Interestingly, one
of the reasons I was looking at light sensors was because our pyroelectric
sensors were erratically sensitive to incandescent light. We wanted a reliable
way to detect bright light and mitigate the effects in software and were
hoping to use an existing component on the board as a sensor (our products
were _extremely_ cost sensitive due to the volume, so adding a $0.12 sensor
was actually a huge deal).

------
jamesadevine
On the microbit [1] we run the display's LEDs in reverse to turn most of the
display into a light sensor [2]. It can then be used in code [3].

[1] [https://microbit.org](https://microbit.org)

[2] [https://lancaster-university.github.io/microbit-
docs/extras/...](https://lancaster-university.github.io/microbit-
docs/extras/light-sensing/)

[3]
[https://makecode.microbit.org/_Lgy9F04ar9Tm](https://makecode.microbit.org/_Lgy9F04ar9Tm)

------
nvahalik
The author of this article is Forest Mims.

Forest Mims wrote RadioShack's Getting Started in Electronics[0] as well as a
number of "mini notebooks"[1]. He is an amazing writer and has a real knack
for explaining things in "layman's" terms.

[0]: [https://www.radioshack.com/products/getting-started-in-
elect...](https://www.radioshack.com/products/getting-started-in-electronics-
book)

[1]:
[http://www.forrestmims.com/engineers_mini_notebook.html](http://www.forrestmims.com/engineers_mini_notebook.html)

~~~
RachelF
He also wrote the manual for the MITS Altair 8800, the microcomputer Bill
Gates and Paul Allen developed BASIC for.

------
ChuckMcM
There are a couple of really cool things you can do with LEDs as detectors.
One is as a wireless link, modulate a red laser pen pointer by putting a
microphone in the battery supply line and then point it at an LED that is
reverse biased on a transistor that is halfway between the on and off state.
Most cheap LED pointer internal power supplies have no filtering for "high
frequency" (greater than about 100hz) noise on the supply line which comes out
as a change in brightness in the pen pointer which the LED can pick up and
drive a transistor amplifier.

The other is a simple "firefly" program where the LED is connected to the ADC
input of a microprocessor, and when it detects LED light it turns around and
flashes the LED some random time in the future. If you have a bunch of these
you can bounce a light around for quite a while.

Chris Kuethe did a great example of this but I cannot seem to find his code
anywhere.

~~~
barbegal
Fireflies: [https://hackaday.com/2009/06/25/64-synchronizing-
fireflies/](https://hackaday.com/2009/06/25/64-synchronizing-fireflies/)

------
DoctorOetker
Fasten your seatbelts:

Using LEDs as SPADs (Single-Photon Avalanche Photodiodes)

[http://nebula.wsimg.com/0b846f1e91ab9c7442a61c8c35680a51?Acc...](http://nebula.wsimg.com/0b846f1e91ab9c7442a61c8c35680a51?AccessKeyId=027C3581808C75E81679&disposition=0&alloworigin=1)

Not sure if that link is shareable, otherwise it's the May 2013 issue "What's
a SPAD?" at
[http://www.teachspin.com/services.html](http://www.teachspin.com/services.html)

~~~
CamperBob2
Very cool. I always enjoy George's posts on sci.electronics.design, and now
I'm going to have to spend some time I don't actually have at the workbench,
trying that.

------
jacquesm
Old diodes were painted black for that reason. If you scraped off the paint
you had a pretty good photodetector. Old transistors ditto (OC71 for
instance), the housings were made of glass so already transparent.

The Germanium ones were more susceptible to this than the Silicon ones.

~~~
aequitas
I remember old books with circuit 'recipies' where you had to sand off the top
of a metal casing transistor to turn it into a detector.

------
askvictor
This is neat; I just recently came across a project using an LED as a candle
you could blow out - using just an LED and microcontroller (no other sensors).
The resistance (hence voltage) change due to the change in heat can be
measured by an ADC.

So, what other hidden talents do LEDs have?

~~~
borgel
Covered here [1] I think? (disclaimer, I write for HaD)

[https://hackaday.com/2018/08/21/an-led-you-can-blow-out-
with...](https://hackaday.com/2018/08/21/an-led-you-can-blow-out-with-no-
added-sensor/)

------
tossandturn
I started reading it, and I thought "this style seems very familiar". When I
got to the first schematic, it clicked and I checked the header for the
author's name; sure enough, Forrest Mims!

------
zunzun
You can use this to make a cheap "toilet-paper-ometer" by sending a 1KHz
square wave to one LED and using a second LED's "detector" output narrowband
filtered for 1KHz. The 1KHz signale makes the "meter" insensitive to ambient
light, and the device is easily calibrated by measuring "detector" amplitude
with different layers and curve fitting the amplitude vs. sheet count. Nice
science fair project for a Raspberry Pi.

~~~
barbegal
How do you implement the 1kHz filter? A 1kHz square wave is easily generated
in software but surely you have to implement the filter using an op-amp and
some passives?

~~~
wallacoloo
Given it's a raspberry pi, you could easily implement the 1 kHz bandpass
filter in software, by sampling at a higher frequency and then implementing a
discrete-time filter. Just about any microcontroller with an ADC could do
that, actually (edit: actually, the raspberry pi doesn't have an ADC - I guess
the author is doing that with a discrete ADC?).

~~~
barbegal
The problem is that most micro-controller ADCs use sample and hold with a
capacitor so they require some time to stabilise. From the source code of
other projects this seems to be on the order of 1 to 5ms which effectively
turns it into a low pass filter.

------
Haitischmock
Is it possible to do this across an entire monitor ? Could the NSA (or anyone
else) be filming us through our screens ?

"We see all through the black mirror"

~~~
londons_explore
I tried this on an oled display (by removing the controller and accessing row
and column lines directly).

Light certainly had some effect, but I didn't get to be able to have the
display show something and act as a sensor at the same time (possibly because
the capacitance of the row and column lines is too high)

~~~
Sephr
What specific display did you try this with? Maybe µLED displays will
eventually be sensitive enough for use as 3d webcams or pupil tracking for
AR/VR.

Capacitive touch screens in lenses can also track pupils using the shape of
the eye.

~~~
DoctorOetker
I would love to learn more about using capacitive touch screen to track
pupils. Is there a specific article or smth you can recommend?

------
Qwertystop
This seems like it ought to be much bigger than it is. Two-way single-cable
fiber-optics, with cheaper components than photoresistors? What's the catch?

~~~
tlb
Detectors for fiber optic data transmission need a very fast response time.
For gigabit data, you need sub-nanosecond response. LEDs are much slower.
They're also less sensitive, which means you need a higher-power transmitting
LED to get the same range.

~~~
monochromatic
What drives the response time, internal capacitance or something?

~~~
tlb
Yes, capacitance of the junction.

~~~
DoctorOetker
That's a rather vague statement, it is the textbook answer directed at the
users of discretes: given a _fixed_ discrete photodiode part and a fixed load
resistor one can change the capacitance by reverse biasing and thus improve
the bandwidth of the resultant RC filter.

But this is not a full truth from the perspective of the photodiode designer:
he can trivially increase or decrease the capacitance by designing a
photodiode with a larger or smaller area. Suppose ratio of the incoming light
power over photodiode area is unaffected by doubling the original photodiode
area. If he doubles the area and hence capacitance, then he also doubles the
injected photocurrent! Hence he can halve the load resistor, hence the
bandwidth is unaffected by doubliing capacitance!

Consider the source illumination, what is the smallest area you can
concentrate the light in? If it is smaller than your photodiode's active area,
it pays off to select a smaller photodiode since the unused area is
contributing dead weight capacitance. But if decreasing the area does not
increase the optical power / photodiode area ratio, you need better optics or
illumination.

EDIT: fixed poorly phrased sentence

------
gioscarab
Ciao, I have played with this characteristic of LEDs since young, those are
some of the results:

\- This is a reflectometer:
[https://github.com/gioblu/PJON/tree/master/devices/sensors/L...](https://github.com/gioblu/PJON/tree/master/devices/sensors/LEDAR)

\- This is a bidirectional wireless data-link:
[https://github.com/gioblu/PJON/tree/master/src/strategies/An...](https://github.com/gioblu/PJON/tree/master/src/strategies/AnalogSampling)

------
rawicki
My favourite application of this idea is concealing a tamper protection switch
in a debug LED.

------
Afrotechmods
I used this phenomenon to build a laser tachometer a while back.
[https://www.youtube.com/watch?v=RfitqGLPCUY](https://www.youtube.com/watch?v=RfitqGLPCUY)

------
Squonk42
You can communicate using bidirectional LEDs:
[http://www.merl.com/publications/TR2003-35](http://www.merl.com/publications/TR2003-35)

------
DataJunkie
This is actually how modern Optical Mark Readers ("Scantron") works. The older
models from the 1960s used electrical current passed through the paper
somehow.

~~~
Johnny555
Scantron readers use LED's as light sensors? I assumed they used regular photo
sensors.

The older form readers used metal brushes that detected the conductivity of
the graphite in pencil lead.

~~~
DataJunkie
It's possible that the "newest" ones use photo sensors as they now also double
as standard desktop scanners, but I'm not sure they would be marketed as OMR.
I suspect Scantron and Pearson NCS won't be around much longer as standard
scanners are much cheaper, can accomplish the same goals (minus printing
results on the form, without a special attachment on expensive scanners), and
embedded processing continues to grow.

------
Robotbeat
I've used LEDs as light detectors in a pinch when I wanted to measure the
rotational speed of something and didn't have any other sensors handy. Neat
trick.

------
cordite
I haven't personally used this feature of PJON, but they have an apparent way
of communicating bidirectionally with a single LED on each side. The one wire
software bit bang method worked for me though.

[https://www.pjon.org/AnalogSampling.php](https://www.pjon.org/AnalogSampling.php)

------
Johnythree
The Optical Communications hobbyists have been using this idea since LEDs
first arrived nearly 50 years ago.

It sure makes things easier to use the same optical system (lens, etc) for TX
and RX.

The only problem is that LEDs make a fairly poor Optical sensor.

------
mark-r
I first heard about this in the 1970's. I tried to build a two-way
communicator on this principle in high school, but never got the circuit to
work.

------
oh5nxo
Are there any other accidentally light sensitive devices?

~~~
detaro
Chips can be, if their case isn't opaque enough. Famous example would be the
"camera shy" Raspberry Pi 2, which crashed when exposed to strong light like a
camera flash: [https://www.raspberrypi.org/blog/xenon-death-flash-a-free-
ph...](https://www.raspberrypi.org/blog/xenon-death-flash-a-free-physics-
lesson/)

Other semi-conductors can be too, e.g. classical diodes in glas casing.

~~~
oh5nxo
Thanks.

I grabbed a multimeter and checked the first part I could find. 1mV DC
covered, 10mV DC uncovered (it's a bleak cloudy day). Magnifying glass reveals
it's a 6v2 zener :)

------
Avery3R
Content? Nah that's overrated let's cover it up with a gigantic sticky header
and footer

------
phendrenad2
TL;DR: LEDs make pretty decent photodiodes. But you should read it. ;)

