News for hackers. Stuff that matters.
Re:Two ways to use an LED as a light sensor with Arduino by brokenmachine on Wednesday June 19, 2024 @10:34PM (#40734331)
Tricky. More than one way to skin a cat.
Re:Two ways to use an LED as a light sensor with Arduino by 2sk21 on Thursday June 20, 2024 @08:35AM (#40738028)
Article like this are why I keep coming back to HN: I was using an LDR (Light Dependent Resistor) for a similar task but this LED idea is fascinating. It would have never occurred to me!
Re:Two ways to use an LED as a light sensor with Arduino by kragen on Thursday June 20, 2024 @10:12AM (#40739002)
the photoresistor is more linear and gives you built-in smoothing over a longer period of time, but (like other photodiodes) the led is much faster
Re:Two ways to use an LED as a light sensor with Arduino by lynndotpy on Thursday June 20, 2024 @08:38AM (#40738053)
Oh this is fun :) I knew LEDs and microphones could be used as light sensors (and vice-versa), but I would never know the specifics of how to do it. I appreciate this.

What other sensors/emitters can be reversed this way?

Re:Two ways to use an LED as a light sensor with Arduino by regularfry on Thursday June 20, 2024 @09:19AM (#40738462)
You can measure temperature with a heating element by measuring the thermal noise. Not sure what circumstances that would be useful in, though.

I can also remember a project that used the arm of a galvanometer as a very sensitive balance for weighing tiny masses, too, which is the same sort of idea but the way it worked was to put a feedback loop around the voice coil and measure the current needed to keep it locked in place against the weight of the sample. https://www.erowid.org/archive/rhodium/chemistry/equipment/s... is a copy of the original article which would probably appear at https://www.scientificamerican.com/id/down-among-the-microgr... if I had access.

Re:Two ways to use an LED as a light sensor with Arduino by kragen on Thursday June 20, 2024 @10:10AM (#40738989)
there's a national instruments demo of using this technique to weigh an eyelash at https://www.youtube.com/watch?v=v68Dica16CU

(although ti claims it's actually them https://www.youtube.com/watch?v=n90whRO-ypE)

Re:Two ways to use an LED as a light sensor with Arduino by HarHarVeryFunny on Thursday June 20, 2024 @11:25AM (#40739787)
You can use a speaker as a microphone, and vice versa.
Re:Two ways to use an LED as a light sensor with Arduino by r2_pilot on Thursday June 20, 2024 @09:09AM (#40738376)
It's helpful to step out of the box with those kinds of questions, and consider what it is the sensor is doing. Abstraction is great for programming and reasoning about complex objects like cars (have key, insert key press pedal to move, that kind of thing), but if you're going to use something like a sensor in a way that it isn't designed, you have to go lower in your abstraction level and look at, for example, the physics of what it's doing. Often a thing that emits can receive what it outputs (if you measure how the membrane of an ultrasonic sound generator is moving, for example, although you'd also have to add additional components at which point it becomes a ping sensor), but sometimes it's not feasible. I really enjoyed Practical Electronics for Inventors for this kind of perspective.
Re:Two ways to use an LED as a light sensor with Arduino by HeyLaughingBoy on Thursday June 20, 2024 @12:37PM (#40740593)
DC motors will generate electricity if you turn them by hand, diodes (including LEDs) make very good temperature sensors (not quite what you asked, but it's useful to know, sometimes).
Re:Two ways to use an LED as a light sensor with Arduino by beambot on Thursday June 20, 2024 @11:52PM (#40745984)
Certain capacitor materials are slightly piezoelectric and can be used as microphones.
Re:Two ways to use an LED as a light sensor with Arduino by EncomLab on Thursday June 20, 2024 @08:43AM (#40738099)
The way those resistors are twisted together makes my heart hurt....

Another fun fact about light and semiconductors is that the first commercial digital camera - the Cromemco Cyclops - used a 32x32 memory ic that used a windowed dip package so the chip was exposed to light. The memory was refreshed to all 1's, and the light would flip them back to 0's with the strongest light flipping the bits the fastest. The times were then parsed and converted to pixel values.

Re:Two ways to use an LED as a light sensor with Arduino by jgrahamc on Thursday June 20, 2024 @08:45AM (#40738110)
I promise I tried to find all my soldering gear.
Re:Two ways to use an LED as a light sensor with Arduino by EncomLab on Thursday June 20, 2024 @09:01AM (#40738286)
lol - it's all good. Props to you for recognizing what was going on and taking the time to research it and make use of it!
Re:Two ways to use an LED as a light sensor with Arduino by petsfed on Thursday June 20, 2024 @02:14PM (#40741535)
If you had the appropriate resistor on hand, you could just a male-to-female jumper to span the distance. Have one lead of the resistor plugged into the female end, and it serves the same purpose as the 3 resistors twisted together.

No sense in soldering this together just for a quick-and-dirty demo, right?

Re:Two ways to use an LED as a light sensor with Arduino by amelius on Thursday June 20, 2024 @03:03PM (#40742066)
I'd use these: https://www.bounceled.com/product/inline-wire-connector/

Yes, they work on resistor leads.

Re:Two ways to use an LED as a light sensor with Arduino by buescher on Thursday June 20, 2024 @01:08PM (#40740911)
I didn't know about the Cromenco camera but I remember seeing the trick in electronics/robotics books from the seventies. Micron sold a windowed DRAM for that purpose back in the early eighties, and I think a camera too. There was a construction article in BYTE.
Re:Two ways to use an LED as a light sensor with Arduino by dmd on Thursday June 20, 2024 @01:31PM (#40741142)
> The way those resistors are twisted together makes my heart hurt....

YKINMKBYKIOK

Re:Two ways to use an LED as a light sensor with Arduino by Terr_ on Thursday June 20, 2024 @09:47PM (#40745385)
That reminds me of a certain edutainment video on shutter-speed and CCDs [0] from long-term Youtube persona "Captain Disillusion". (Skip to ~4m for the CCDs.)

[0] https://www.youtube.com/watch?v=28S47EE_opA

Re:Two ways to use an LED as a light sensor with Arduino by rpaddock on Thursday June 20, 2024 @08:57AM (#40738232)
Similar things have been around for a while and there are several variations to be found for the AVR, using the I/O pins rather than the ADC.

See US Patent 6,870,148 B2 March 22 2005 "LED WITH CONTROLED CAPACITIVE DISCHARGE FOR PHOTO SENSING" by Mitsubishi Electric Research Lab (MERL). https://image-ppubs.uspto.gov/dirsearch-public/print/downloa...

Also:

Dietz, P.H., Yerazunis, W.S., Leigh, D.L., "Very Low-Cost Sensing and Communication Using Bidirectional LEDs", ACM International Conference on Ubiquitous Computing (UbiComp), October 2003. BibTeX TR2003-35 - https://www.merl.com/publications/TR2003-35

Which is good for ~30 Baud and distances of inches at best.

https://people.ece.cornell.edu/land/courses/ece4760/FinalPro...

https://forum.chibios.org/viewtopic.php?t=2179

Re:Two ways to use an LED as a light sensor with Arduino by bloopernova on Thursday June 20, 2024 @10:01AM (#40738896)
> Which is good for ~30 Baud and distances of inches at best.

This feels like it would be part of the plot of a Neal Stephenson or Andy Weir book.

Our intrepid hero has to send super secret plans to save humanity through glass to his partner, so they can prevent Jupiter going supernova! But the Bad Guys are jamming wifi signals!

Re:Two ways to use an LED as a light sensor with Arduino by dangets on Thursday June 20, 2024 @10:44AM (#40739311)
As a university project I created a Morse code transmitter and receiver circuit that used the same type of LED on both sides. It worked pretty well up to a few inches apart.
Re:Two ways to use an LED as a light sensor with Arduino by regularfry on Thursday June 20, 2024 @09:06AM (#40738343)
I remember a project in Scientific American many years ago which proposed using a distributed bunch of sensors using reverse-biased green LEDs to measure atmospheric pollution levels, but I can't immediately find it now.
Re:Two ways to use an LED as a light sensor with Arduino by rpaddock on Thursday June 20, 2024 @09:11AM (#40738389)
Internet Search has become near useless of late, regardless of which Search Engine is used.

Hopefully you find it and let us know.

Forrest Mims was the first to propose using the LED as a sensor in the early 70s, not long after LEDs became common.

https://hackaday.com/2015/10/13/citizenscience/

Re:Two ways to use an LED as a light sensor with Arduino by detourdog on Thursday June 20, 2024 @09:49AM (#40738768)
Archive.org is the closest thing I have found for the old internet. If I'm interested in a topic the first I go to is archive.org.
Re:Two ways to use an LED as a light sensor with Arduino by kragen on Thursday June 20, 2024 @10:25AM (#40739135)
probably you should donate and also see if you can save what you can: https://www.youtube.com/watch?v=a4KkiKDKw88

governments burn libraries

Re:Two ways to use an LED as a light sensor with Arduino by jgrahamc on Thursday June 20, 2024 @09:11AM (#40738391)
Probably something from Forrest Mims. I have his stuff going back to the 1970s and he was using LEDs like this for all sorts of communication and environmental stuff way back.
Re:Two ways to use an LED as a light sensor with Arduino by regularfry on Thursday June 20, 2024 @09:31AM (#40738587)
Re:Two ways to use an LED as a light sensor with Arduino by regularfry on Thursday June 20, 2024 @09:26AM (#40738539)
Very probably. This isn't it, but it's very closely related: https://www.researchgate.net/publication/243581659_LED_sun_p...
Re:Two ways to use an LED as a light sensor with Arduino by rpaddock on Thursday June 20, 2024 @09:14AM (#40738419)
Yes. We both posted that he originated the idea at the same time.
Re:Two ways to use an LED as a light sensor with Arduino by kragen on Thursday June 20, 2024 @10:07AM (#40738957)
the distance and baud rate depend a lot on the specific led you're using and how you're measuring it
Re:Two ways to use an LED as a light sensor with Arduino by icpmoles on Thursday June 20, 2024 @09:12AM (#40738401)
I remember the OG pebble using the backlight LEDs as ambient light sensors but I can't find where I read it.
Re:Two ways to use an LED as a light sensor with Arduino by kragen on Thursday June 20, 2024 @10:06AM (#40738944)
this was one of the first things i did with an avr. it's a little more challenging on an attiny2313, because it doesn't have an adc: http://canonical.org/~kragen/light_sensing/
Re:Two ways to use an LED as a light sensor with Arduino by NietTim on Thursday June 20, 2024 @10:34AM (#40739219)
Bought a "proper" light sensor last week but would've fit my needs. D'oh!
Re:Two ways to use an LED as a light sensor with Arduino by mikewarot on Thursday June 20, 2024 @10:51AM (#40739399)
Decades ago, I built a sensor that detected a break in a path to a retro-reflector up to 6 feet away using a single bi-color LED and some op amps, etc. I don't remember all the details... but I did learn how the photoelectric effect works, in my gut.

A red LED emits a lower energy photon than a green LED. Each will pick up their own reflections, but the green LED will not pick up the light from the red one.

Re:Two ways to use an LED as a light sensor with Arduino by zoky on Thursday June 20, 2024 @11:14AM (#40739655)
Well I guess if a generator is just a motor run backwards then this stands to reason…
Re:Two ways to use an LED as a light sensor with Arduino by dragontamer on Thursday June 20, 2024 @11:33AM (#40739880)
Note: a photodiode is an expressly measured diode that does this job.

An LED is still a photodiode, as this blogpost noted. But you'll get more consistent results with a real photodiode (or phototransistor, if you want a bit of amplification added in)

----------

Obviously the diode works here and for this project. But given higher levels of sophisticated photosiodes (but still a similar circuit), you can choose photosiodes that detect infrared light

We humans light up like a light bulb in the infrared spectrum. So two IR Photodiodes is all you need for a human motion sensor.

A motion sensor detects motion by looking at two pixels of IR light. Motion is 'defined' as one pixel lighting up.... Followed by the second pixel lighting up. If only one pixel lights up, then no motion (it's just a glitch). Real motion should show up across both pixels in a slight time delay fashion.

IR Photodiodes (or phototransistors) are used because it's the spectrum of light humans shine the most brightly in, despite being invisible to us humans it's the best sensor at the electronics level for these purposes.

---------

There really isn't much electrical complexity to the motion sensor that this blogpost was trying to debug.

I would suggest building your own motion sensor as the next step in your EE journey.

Re:Two ways to use an LED as a light sensor with Arduino by Kerbonut on Thursday June 20, 2024 @05:17PM (#40743500)
So can LED screens be used as a camera?
Re:Two ways to use an LED as a light sensor with Arduino by dragontamer on Thursday June 20, 2024 @05:31PM (#40743627)
The "D" in LED is "Diode", commonly referring to the "P-N Junction" and its capabilities.

A CMOS sensor is an array of thousands of photodiodes. So erm... diodes are _already_ used as the basis of modern digital cameras.

I guess building one out of LEDs (diodes designed to emit light, rather than receive it) is feasible but I can't imagine it'd work very well. If you build a big enough camera and calculate the right lenses, it probably would work. But it wouldn't surprise me if the proper size of such a camera was on the order of a 20-feet by 30-foot room (with a "camera sensor" the size of maybe 5-feet by 5-feet, composed of thousands of LEDs acting as terrible photodiodes).

--------

A proper CMOS sensor miniturizes all of that to happen on a micrometer scale, so you can shrink modern cameras down to... well... the size of our phones.

But the principles of light, sensors, and cameras in general work even with larger / inefficient objects. You just got to build a "large enough" camera to compensate for all the problems.

EDIT: And also what the other poster pointed out about the control circuitry. The circuits in a typical LED Screen are all "output only". There's no way for the information to come back / reverse the LED Screen because the circuits are already set. I'm assuming you're somehow building those circuits and have embedded them into the LEDs somehow.

Re:Two ways to use an LED as a light sensor with Arduino by nialv7 on Friday June 21, 2024 @01:39AM (#40746507)
hmm, can I use a digital camera sensor as screen then?
Re:Two ways to use an LED as a light sensor with Arduino by londons_explore on Friday June 21, 2024 @02:00AM (#40746631)
You would have to rewire the sensor internally, which considering it's a silicon chip ain't gonna happen.

Also, it would be an infrared screen.

Re:Two ways to use an LED as a light sensor with Arduino by immibis on Thursday June 20, 2024 @05:31PM (#40743623)
No. Even if each LED was a good light sensor (it's not good) the control circuitry is output-only. And you need a lens, or else every pixel receives the light from all around it, and reads just the average brightness of the room.
Re:Two ways to use an LED as a light sensor with Arduino by Zenst on Thursday June 20, 2024 @10:30PM (#40745581)
Yes, if you just want to record shadow puppets.

https://en.wikipedia.org/wiki/Shadow_play

Re:Two ways to use an LED as a light sensor with Arduino by frankus on Thursday June 20, 2024 @11:36AM (#40739911)
I remember a coworker telling me about a project that had mysterious battery drain after shipping.

It turns out the microcontroller was doing read-modify-write on a port that had an LED connected, and in bright sunlight the LED input would be high, and then stay high after the write. It was fixed with a firmware update that set the LED bit based on whatever logic determined if it should be on on every write.

Re:Two ways to use an LED as a light sensor with Arduino by yonatan8070 on Thursday June 20, 2024 @12:13PM (#40740350)
I know someone who made digital candles using the technique for Hannukkah (Jewish holiday), there was a set of LEDs connected like shown in the post, and you could use your a flashlight (or a purpose built "shammash" LED) to turn each candle/LED on by touchibg it with a light, it was quite cool
Re:Two ways to use an LED as a light sensor with Arduino by jgrahamc on Thursday June 20, 2024 @12:22PM (#40740441)
Very cool. I like that.
Re:Two ways to use an LED as a light sensor with Arduino by anfractuosity on Thursday June 20, 2024 @12:30PM (#40740530)
Re:Two ways to use an LED as a light sensor with Arduino by 123pie123 on Thursday June 20, 2024 @02:49PM (#40741902)
thanks for the link - i was looking for something like this to create a more realistic led candle that detects drafts and makes them flicker slightly quicker
Re:Two ways to use an LED as a light sensor with Arduino by dmitrygr on Thursday June 20, 2024 @12:53PM (#40740763)
Basically a slightly less polished version of this: [1] [2]

The above paper goes further implementing two way comms using only a LEDs

[1] https://www.researchgate.net/publication/221568729_Very_Low-...

[2] https://courses.cs.washington.edu/courses/cse590u/03su/paper...

Re:Two ways to use an LED as a light sensor with Arduino by antirez on Thursday June 20, 2024 @01:01PM (#40740847)
Other two reversible effects that are not cited in the thread:

1. Peltier effect. 2. Piezoelectric effect.

The second one is especially useful in DYI stuff since you can use a piezo speaker in order to generate a current when mechanically stressed.

Re:Two ways to use an LED as a light sensor with Arduino by anfractuosity on Thursday June 20, 2024 @01:18PM (#40741016)
Have you come across https://en.wikipedia.org/wiki/Quartz_crystal_microbalance re. the piezoelectric effect, you can apparently measure very small masses.

(It sounds like you do need to apply an alternating current for this though)

Re:Two ways to use an LED as a light sensor with Arduino by antirez on Friday June 21, 2024 @05:58AM (#40747925)
Cool. Yep, piezos only produce current while the mechanical stress changes its shape, but if the load is stable, no current is performed, so I guess that's the reason why you need to apply an alternating current to it in order to use it that way. Thanks.
Re:Two ways to use an LED as a light sensor with Arduino by jIyajbe on Thursday June 20, 2024 @01:16PM (#40740991)
The reversed-biased method is actually the basis of single-photon detectors used in quantum optics experiments, especially experiments with entangled photons. Here's a paper that uses exactly this--reversed-biased red LEDs-- to introduce physics undergrads to the essential concepts:

https://advlabs.aapt.org/items/detail.cfm?ID=13808

It includes a simple circuit that probably anyone here on HN could build. (Even me!)

Re:Two ways to use an LED as a light sensor with Arduino by anfractuosity on Thursday June 20, 2024 @04:35PM (#40743077)
Very cool, you might like this - https://research-information.bris.ac.uk/ws/portalfiles/porta...

A single photon source from an LED. I need to read it more closely, but was curious if it could be used to create a quantum RNG.

Re:Two ways to use an LED as a light sensor with Arduino by jIyajbe on Thursday June 20, 2024 @05:02PM (#40743328)
I read the paper; much of the electronics details got past me on the first read, but I think that the part most relevant to your question is their statement that it needs to be determined if the LED is a deterministic or a probabilistic single-photon light source.
Re:Two ways to use an LED as a light sensor with Arduino by anfractuosity on Thursday June 20, 2024 @05:33PM (#40743640)
Yeah, that's a good point, I've just been looking at - https://en.wikipedia.org/wiki/Single-photon_source#Character... which talks a little about what deterministic means with respect to a single photon source.

It sounds like if it's probabilistic it could also generate multiple photons.

Re:Two ways to use an LED as a light sensor with Arduino by floitsch on Thursday June 20, 2024 @01:31PM (#40741144)
I used this technique to send data from the cell-phone to an ESP32 using the phone's flashlight: https://www.reddit.com/r/esp32/comments/wfea4r/send_data_wit...
Re:Two ways to use an LED as a light sensor with Arduino by persnickety on Thursday June 20, 2024 @01:48PM (#40741289)
"the LED [...] will act as a capacitor that charges when light hits it."

Wait, what? Photodiodes are supposed to be letting (dark) current through continuously when light hits them in reverse bias. Heck, I even tested it empirically myself, and the light was continuous.

On this topic, what kind of light detector is the most linear? Photodiode? Phototransistor? Photoresistor? Something else?

I'm thinking about connecting it to a white LED to have an ambient-aware light.

Re:Two ways to use an LED as a light sensor with Arduino by dfox on Thursday June 20, 2024 @01:49PM (#40741301)
Twenty years ago (when building community wireless networks was all the craze, at least here), we played with free-space optics and in course of that found out that random soviet (4mm!) green LED from parts bin makes exceptionally good receiver for the red laser LED from cheap laser pointer (driven by bunch of paralleled up HC04 gates). The contraption was not really practical, but across few meters of lab bench had higher bandwidth than we could measure with the surplus 50MHz CRO we had there.
Re:Two ways to use an LED as a light sensor with Arduino by mmoustafa on Thursday June 20, 2024 @01:51PM (#40741321)
> Certainly looks like that motion sensor is turning the light on in the night uselessly.

Have you seen the movie Parasite?

Re:Two ways to use an LED as a light sensor with Arduino by DoingIsLearning on Thursday June 20, 2024 @05:04PM (#40743361)
> Certainly looks like that motion sensor is turning the light on in the night uselessly.

Interesting read John but since no one brought it up you should be careful to assume the sensor is at fault.

Hypothetically the timestamps in the example (roughly 00:00 to 04:00) sound like a fine time for rodents to roam and many motion sensors will also trigger on our small mass friends. :)

Re:Two ways to use an LED as a light sensor with Arduino by lolc on Thursday June 20, 2024 @05:55PM (#40743861)
Oh that was an interesting dive into LED peculiarities. And I did have an oddly behaving movement sensor too! It turned out to be mice. The sensor was just very sensitive.