(article continued from previous page)
The prior page introduced the photovoltaic effect of a reversed LED and the theoretical method for turning it into a useful color sensor. Now, let’s move on to a practical implementation.
Rather than starting with a partial circuit and building up, I’m going to cheat a bit and show a complete working implementation. Although this circuit is still based on the photodiode op amp core, the complete circuit also includes:
Officially, the circuit can work with a single reversed LED of any color without requiring a matching LED light source. But, by starting out with this best-case configuration, it is more likely that you'll have successful results on your first try. Later on, if you choose a different color (like green or blue) you'll need to use higher resistor values and a lot more LEDs to get this to work on a leaky solderless breadboard.
If it seems complex at first, don’t panic. Note that there are a lot of extra parts to provide an interactive experiment.
Complete schematic for detecting color with a reversed LED and a high-gain op amp.
A reader asked me if the schematic has an error: Shouldn’t LED9 and R9 be connected to ground, not +5V, in order to turn on when LED1 sees light?
The schematic is correct. I pulled the breadboard out of storage and confirmed it is working. This op amp is wired in an inverting configuration, which is confusing.
There is a tug of war between R1 and LED1. R1 would like to saturate the output high. But, as more light reaches LED1, it drains away current from R1 and into ground. Thus, the more light that reaches LED1, the lower the voltage at input A- (pin 2).
However, because input A+ (pin 3) is connected to ground, and input A- is connected to a voltage above ground, the output (pin 1) is the opposite of input A- (pin 2). This is known as an inverting amplifier. Therefore, the more light that reaches LED1, the lower the voltage at input A- (pin 2), the higher the voltage at the output (pin 1).
The same thing happens on the other half of the chip. When input B- (pin 6) is higher, output B is lower. Thus, LED9 should be made to light up when output B goes low.
Light high = LED1 more drain = input A- lower = output A high (inverted) = input B- high = output B low (inverted)
Light low = LED1 less drain = input A- higher = output A low (inverted) = input B- low = output B high (inverted)
I always like to include a photograph of a circuit on a solderless breadboard to help people lay it out.
Solderless breadboard with a pair of reversed LEDs and a low-input current op amp to act as a color sensor.
When the circuit receives 5V from a power supply not pictured, indicator LED9 will turn on when light reflects from LED5 into either or both reversed LEDs that are labeled LED1. This is usually accomplished by placing a hand or a piece of paper an inch or so over LED5 and angling the light into LED1.
If you have an overhead lamp or sun shining onto the board, the reversed LEDs may always be detecting light and LED9 may always be turned on. Remember, white light is a combination of multiple colors and wavelengths. Cover the board with a cloth or cardboard box and then move your hand up and down above the reversed LEDs to vary the amount of reflected light.
Trimmer R8 determines the detection voltage needed to turn on indicator LED9. If LED9 turns on with too little light or turns off with too much light, adjust R8.
Connect a multimeter in voltage mode to the start or the end of the green wire (IC1 pin 1 or pin 6) to measure the amplified voltage level of the reversed LEDs. If the voltage is too high and doesn’t seem to decrease when LED1 is shadowed, remove some resistance from R1 or pull out one of the reversed LEDs. If the voltage is too low and doesn’t seem to increase when LED1 is placed under a bright light, add some resistance to R1.
Don’t attempt to measure the voltage directly from LED1 or IC1 pin 2. Most multimeters require too much current at their inputs and will simply drive down the already faint voltage on the reversed LEDs. Instead, measure the amplified voltage at IC1 pin 1 or pin 6.
A better way to measure the voltage of a low-power analog signal is to use an oscilloscope. Because many readers don’t own oscilloscopes, the remainder of this article consists of a group of oscilloscope traces I took along the way of developing this circuit.