Why? I have no idea. May be a cool trick for someone looking for an easy and cheap method for tuning gain. Or not.
Light Dependent Resistors (LDR) have fairly slow resistance change to input light changes, but LEDs can be toggled very quickly (at least much faster than LDR response). I was curious if this could be exploited to make a programmable gain amplifier. The microcontroller can PWM the LED (with a high enough frequency), and the gain range SHOULD be related to the PWM resolution.
There are some issues:
1) It is a dumb idea
2) LDRs do not have a well defined resistance, so this can't give very useful absolute gain values without calibration
At the same time, this stupid idea is kind of cool:
1) It uses really cheap components
2) It is simple to implement, and easy to interface with nearly any MCU. No I2C or SPI interfaces needed
I also would not be surprised if this is done inside some other parts in a better way. Leave a comment if you know of one.
To prove the idea, I set up an inverting amplifier. I used a TLV2462 operational amplifier, since that is what I had on hand. This has a gain-bandwidth product of 6.5MHz, and rail-to-rail output. I planned to put a roughly 500Hz square wave out of an Arduino PWM through it, so this was good enough.
The gain here was:
The resistance from the LDR ranged roughly from 1k to 13k from dark to bright LED flashlight onto it. The second LED I had was 200 Ohm, so the amplifier had below unity gain. I drove the LED with a PWM of frequency roughly 60kHz, and ramped through its 8-bits of resolution. Looking at the output on the scope, it works!
So, yes, it does work, its janky, but maybe someone would have a use for it.