Scherz & Monk, Chapter 5

Optoelectronics: Light from Current, Current from Light

Every optoelectronic part rests on one fact: an electron crossing an energy gap either spits out a photon or is knocked loose by one. Run that physics forward and you get an LED; run it backward and you get a solar cell. This chapter turns that single idea into glowing displays, light sensors, and circuits that talk without touching.

Prerequisites: Ohm's law & the divider rule (Ch 2) + diodes, PN junction, anode/cathode (Ch 4)
17
Chapters
4+
Simulations
0
Assumed Knowledge

Chapter 0: The Dead LED

You buy two identical red LEDs. You take the first, push its longer leg (the anode) onto the + terminal of a fresh 9 V battery and its shorter leg (the cathode) onto the − terminal. It flashes — bright, just for an instant — and then it is dark forever. A faint smell of hot plastic.

Your friend takes the second LED, solders a small resistor in series with it, and connects that across the same 9 V battery. Hers glows a steady, cheerful red. It is still glowing a year later. Same part, same battery. One died in a heartbeat; one lives indefinitely. The only difference is a part that cost less than a penny.

This is not a trick. It is the central fact of optoelectronics, and it follows from how an LED behaves electrically. An LED is a diode: once it conducts, it clamps the voltage across itself to a nearly fixed forward voltage Vf (about 1.8 V for red) and then it barely resists current at all. Its I–V curve is almost vertical past Vf. So when you put 9 V across a part that only ever drops 1.8 V and has near-zero internal resistance, Ohm's law screams: the current shoots toward whatever the battery can deliver — hundreds of milliamps — far past the ≈20 mA the chip can survive. The junction overheats and fails in milliseconds.

The resistor fixes everything by eating the leftover voltage. Of the 9 V, the LED keeps its 1.8 V; the resistor must drop the remaining 7.2 V. Choose the resistor so that dropping 7.2 V corresponds to a safe 20 mA, and the LED is protected. The whole rest of this chapter is the physics that makes Vf what it is, and the engineering of that one resistor — plus everything that happens when you run the same junction in reverse and let light make the current instead.

LEDs are current devices, not voltage devices. You never "apply a voltage" to an LED and hope. You decide on a current (usually ~20 mA), and then you build a circuit that delivers exactly that current. The series resistor is the current-setting element. Forget it and the LED is a near short-circuit across your supply.
The Two Circuits, Side by Side

Left: bare LED across 9 V — runaway current, dead part. Right: LED with a 360 Ω resistor — pinned to 20 mA. Click Connect Power to energize both. Watch the current readouts.

What you'll be able to do by the end

You will compute the right resistor for any LED on any supply, predict the forward voltage of an LED from its color, drive seven-segment displays and series strings, read light with a photoresistor, harvest power with a solar cell, and isolate one circuit from another with an optocoupler — all from the one electron-photon idea.

Why does an LED wired directly across a 9 V battery (no resistor) burn out almost instantly?

Chapter 1: Photons & the Spectrum

Before we can explain why a red LED and a blue LED behave differently, we need to know what light is from a circuit's point of view. Light is a stream of photons — discrete packets of electromagnetic energy. Each photon carries a fixed amount of energy set entirely by its frequency, and frequency is just another name for color.

The defining relation is Planck's: the energy of one photon equals Planck's constant times its frequency. And since all electromagnetic waves travel at the speed of light c, frequency and wavelength are locked together by c = fλ. Combining the two gives the form we use constantly:

E = h·f = h·c / λ

where h = 6.63×10−34 J·s and c = 3.0×108 m/s. The key takeaway: shorter wavelength means higher energy. Blue light (short λ) is more energetic than red light (long λ). That single inequality is what forces a blue LED to need a higher forward voltage than a red one — a fact we'll cash out in Chapter 3.

Visible light occupies a narrow slice of the electromagnetic spectrum, roughly 400 nm (violet) to 700 nm (deep red). Below 400 nm is ultraviolet; above 700 nm is infrared (the "color" your TV remote and a CD laser emit, invisible to your eye but plain to a photodiode). The everyday LED colors live at: red ≈650–660 nm, orange/yellow ≈590–610 nm, green ≈565 nm, blue ≈470 nm.

Worked example: the energy of green light

Take a green LED emitting at λ = 565 nm = 565×10−9 m. Its photon energy is:

E = (6.63×10−34 · 3.0×108) / (565×10−9) = 1.989×10−25 / 5.65×10−7 ≈ 3.52×10−19 J

Dividing by the charge on one electron (1.6×10−19 C) converts joules to electron-volts: 3.52×10−19 / 1.6×10−192.2 eV. The frequency is f = c/λ = 3.0×108 / 565×10−9 ≈ 5.31×1014 Hz — 531 trillion oscillations per second.

Now compare blue at λ = 470 nm: E = (1.989×10−25)/(470×10−9) ≈ 4.23×10−19 J ≈ 2.6 eV. Blue photons carry about 20% more energy than green, and that gap shows up directly at the LED's terminals as a higher forward voltage.

Color is energy, energy is voltage. An LED's color is not a paint job — it is a direct readout of the energy each electron loses when it crosses the junction. A 2.2 eV drop emits a 2.2 eV (green) photon; a 2.6 eV drop emits blue. The "electron-volt" unit is literally telling you the volts: a 2.6 eV band gap means electrons fall through about 2.6 V, which is why blue LEDs have a forward voltage near 3 V while red ones sit near 1.8 V.

Wavelength → Color & Energy Mapper

Drag the wavelength slider across the visible band. The panel paints the actual color and computes the photon energy E = hc/λ (in joules and eV) and frequency f = c/λ live.

Wavelength λ 565 nm
Which photon carries the most energy?

Chapter 2: How an LED Glows

An LED is a light-emitting diode — a PN junction, just like the diodes in Chapter 4, but built from semiconductor compounds whose physics make it dump its energy as light rather than as heat. To see how, recall what a forward-biased junction does to its charge carriers.

On the N side of the junction there are mobile electrons; on the P side there are holes (empty bonds that behave like positive charges). When you forward-bias the diode — positive on the P side (anode), negative on the N side (cathode) — you push electrons toward the junction and holes toward it too. At the junction they meet and an electron drops into a hole. This is recombination.

Here is the crucial part. An electron in the N-side conduction band sits at a higher energy than a hole in the P-side valence band. When it recombines, it must shed that energy difference. The size of that difference is the material's band gap Eg. In ordinary silicon diodes the energy leaks out as heat (lattice vibrations). In LED materials — gallium arsenide, gallium nitride, and their alloys — the electron instead emits a single photon whose energy equals the band gap:

Ephoton = Eg  ⇒  λ = h·c / Eg

So the band gap chosen by the chemist sets the photon energy, which sets the wavelength, which sets the color. A wide-gap material (gallium nitride, ~2.6 eV) emits blue; a narrower gap (gallium arsenide phosphide) emits red. And because the electron has to fall through that band gap, the forward voltage you must apply is approximately Eg expressed in volts — wider gap, higher Vf. This is the through-line: band gap → color → forward voltage, all the same number wearing different clothes.

Why one fact ties color and voltage together

For a green LED we found a 2.2 eV photon. That implies a band gap of about 2.2 eV, which implies a forward voltage of roughly 2.0–2.1 V (a little less than the ideal because of how the junction conducts). For blue at 2.6 eV, Vf climbs to ~3.2–3.4 V. For red at ~1.9 eV, Vf ≈ 1.8 V. You can practically read an LED's color off its datasheet's Vf and vice versa — they are the same physics.

Why LEDs only pass current one way. An LED is still a diode, so it only conducts (and only lights) when forward-biased. Reverse it and it blocks — and unlike a rectifier diode, an LED's reverse breakdown voltage is low (often just 5 V). Connect one backwards across enough voltage and you can destroy it. Get the anode (long leg / round side) and cathode (short leg / flat side) right.
Recombination at the Junction

An electron (teal) crosses the junction, drops into a hole (warm), and emits a photon of energy equal to the band gap. Slide the band gap to change the color of the emitted light — wider gap, bluer photon, higher Vf.

Band gap Eg 2.20 eV
What physically sets the color of the light an LED emits?

Chapter 3: Sizing the Current-Limiting Resistor

Now we solve the dead-LED problem for real. We have a supply voltage Vin, an LED that drops a fixed Vf, and a target current ILED (usually about 20 mA). We need the series resistor Rs that makes it all work. Kirchhoff's voltage law says the voltages around the loop must add to the supply:

Vin = Vf + ILED·Rs

The resistor carries the same current as the LED (they're in series) and must absorb everything the LED does not. Solving for Rs gives the single most-used formula in hobby electronics:

Rs = (Vin − Vf) / ILED

Read it as: leftover voltage divided by desired current. The "leftover voltage" Vin − Vf is exactly the 7.2 V the resistor had to eat in Chapter 0. Bigger supply → more leftover → bigger resistor. Higher Vf (bluer LED) → less leftover → smaller resistor.

Worked example A: red LED on 9 V

Red LED, Vf = 1.8 V, target I = 20 mA = 0.020 A, supply 9 V:

Rs = (9 − 1.8) / 0.020 = 7.2 / 0.020 = 360 Ω

360 Ω is not a standard E12 value, so round up to the nearest standard part: 390 Ω. Rounding up gives slightly less current, which is the safe direction (slightly dimmer, never overdriven). With 390 Ω the actual current is (9−1.8)/390 = 18.5 mA — perfect.

Always check the resistor's power rating

The resistor is dissipating real power and you must not exceed its wattage. With the 360 Ω value:

P = I2·R = (0.020)2 × 360 = 0.0004 × 360 = 0.144 W

That's 144 mW, comfortably under the 250 mW of a standard ¼ W resistor. (Equivalently P = VR·I = 7.2×0.020 = 0.144 W — same answer.) On a lower 5 V supply the leftover is smaller, so both R and its power drop; on a 24 V supply with one LED, the resistor eats ~22 V and dissipates far more — always check.

If you don't know Vf, guess smart. No datasheet handy? Assume Vf ≈ 2 V for red/yellow/green and ~3.3 V for blue/white, and target 20 mA. The formula is forgiving: a 10% error in your guessed Vf on a 9 V supply shifts the current by only a couple of percent, because the leftover voltage dominates. The higher your supply relative to Vf, the less your Vf guess matters.
SHOWCASE — LED Resistor Calculator & Current Gauge

Pick an LED color (loads its Vf), set the supply and target current. The widget computes Rs, the nearest standard resistor, the resulting current, and resistor power — and drives a live brightness gauge. Hit Remove Resistor to short it out and watch the LED blow.

LED color
Supply Vin 9.0 V
Target current 20 mA
An LED with Vf = 2.0 V is driven at 20 mA from a 5 V supply. What series resistor do you need?

Chapter 4: LED Circuit Gotchas

One LED with one resistor is the easy case. Real projects use many LEDs — strings, matrices, RGB units, numeric displays. The mistakes people make almost all come from forgetting that LEDs are current devices with a clamped voltage.

Series strings: add the forward voltages

Put several LEDs in series and the same current flows through all of them — so they're equally bright, which is exactly what you want. Their forward voltages add up. The resistor formula generalizes by summing Vf:

Rs = (Vin − n·Vf) / ILED

Worked example C: four white LEDs (Vf = 3.4 V each) in series need 4×3.4 = 13.6 V of drop. From a 24 V supply at 20 mA: Rs = (24 − 13.6)/0.020 = 10.4/0.020 = 520 Ω. There is a hard limit: the sum n·Vf must stay below your supply (with margin). A good rule is to keep the total LED drop under ~80% of Vin, leaving the resistor enough headroom to actually regulate current as the supply sags.

Parallel: never share one resistor

It is tempting to wire several LEDs in parallel behind a single resistor. Don't. Real LEDs have slightly different Vf values, and the one with the lowest Vf hogs almost all the current — it runs bright and hot while the others stay dim, then it burns out and dumps its current into the next one. The fix: one resistor per LED branch, so each branch sets its own current independently.

Seven-segment displays

A seven-segment display is just seven (plus a decimal point) LEDs arranged as a figure-8, labeled a–g. Light the right subset and you form any digit 0–9. In a common-cathode display all cathodes join to ground and you drive each segment's anode high (through its own resistor); in common-anode it's the mirror image. Each lit segment still needs current limiting — one resistor per segment, sized with the same Rs = (Vin−Vf)/I formula.

RGB and blinking are combinations of the basics. An RGB LED is three dies (red, green, blue) in one package sharing a common pin — three resistors, three Vf values, and you mix colors by varying each current (often via PWM). A "blinking" LED has a tiny oscillator chip built in. Neither changes the rule: every die that emits light needs its current set by a series resistor.
Seven-Segment Display Driver

Click individual segments (a–g) to toggle them, or press a number button to light the correct pattern. This is common-cathode wiring — each segment is one LED to ground.

Why should you avoid putting several LEDs in parallel behind a single shared resistor?

Chapter 5: Detecting Light — the Photoresistor

So far we've run the electron-photon trade in one direction: current in, light out. Now run it backward. If a photon can carry away energy when an electron recombines, then a photon can also deliver energy to liberate an electron. That is the basis of every light sensor in this chapter, starting with the simplest: the photoresistor.

A photoresistor (also LDR, light-dependent resistor, usually made of cadmium sulfide, CdS) is a resistor whose value depends on how much light hits it. In the dark, few electrons are free, so resistance is high — often megohms. Under bright light, photons knock loose many carriers, resistance plunges to hundreds of ohms. The relationship is inverse: more light → less resistance.

By itself a changing resistance does nothing useful — you can't read it directly. The trick is to put the LDR in a voltage divider with a fixed resistor, turning resistance changes into voltage changes that a microcontroller or comparator can read. From Chapter 2, the divider output is:

Vout = Vin · R2 / (R1 + R2)

Which leg the LDR occupies decides the polarity of the response. Put the LDR on top (R1) and a fixed resistor on the bottom (R2): in bright light the LDR is small, so most of Vin appears across R2 and Vout is high — a light-activated output. Swap them and you get a dark-activated output, the classic automatic-nightlight circuit.

Worked example: the divider in dark and light

Use Vin = 5 V, a fixed R2 = 10 kΩ on the bottom, and the LDR as R1 on top. In darkness the LDR is ~1 MΩ:

Vout = 5 × 10k / (1000k + 10k) = 5 × 0.0099 ≈ 0.05 V (near 0 — "dark")

In bright light the LDR drops to ~1 kΩ:

Vout = 5 × 10k / (1k + 10k) = 5 × 0.909 ≈ 4.55 V (near 5 — "light")

So one cheap part swings the output from 0.05 V to 4.55 V as the room goes from dark to bright — a clean, readable signal. Feed it into a comparator with a threshold around 2.5 V and you have a switch that flips when the light crosses a level you choose.

Pick R2 near the LDR's mid-range. The divider is most sensitive (biggest Vout swing per unit light) when the fixed resistor roughly matches the LDR's resistance at the light level you care about. Choose R2 to be the geometric mean of the LDR's dark and light values, and the threshold lands right in the middle of your usable range — not pinned near 0 or Vin.
Photoresistor Divider: Light vs Dark

Drag the flashlight brightness to drop the LDR's resistance from megohms (dark) to hundreds of ohms (light). The voltmeter reads Vout live. Toggle which leg the LDR occupies to flip between light-activated and dark-activated.

Light level 50%
As the light hitting a photoresistor (LDR) increases, its resistance...

Chapter 6: Photodiodes, Solar Cells & Phototransistors

The photoresistor is slow and crude. The precise light detectors are PN-junction devices run in reverse — the very same junctions that make LEDs, now used as receivers. When a photon with energy above the band gap strikes the depletion region, it knocks an electron free, creating an electron-hole pair. The junction's built-in field sweeps them apart into a current. Light in, current out: an LED run backward.

Photodiode: two ways to use it

A photodiode is a PN junction optimized to catch light. You can operate it in two modes:

Solar cell: a big photodiode that powers things

A solar cell is simply a large-area photodiode in photovoltaic mode. Each silicon cell produces an open-circuit voltage of about 0.45–0.5 V in full sun, almost independent of size; the area sets the current. To get useful voltages you wire cells in series (their voltages add, just like series LED Vf): a "12 V" panel is ~36 cells in series. For more current, wire strings in parallel.

Worked example: you want ~6 V to charge a battery. At 0.5 V per cell, you need 6/0.5 = 12 cells in series. If one cell delivers 0.1 A in your light and you need 0.3 A, put three such 12-cell strings in parallel: 0.5×12 = 6 V at 3×0.1 = 0.3 A.

Phototransistor: built-in gain

A phototransistor is a transistor whose base current comes from light instead of a wire. The photo-generated current at the base-collector junction is amplified by the transistor's gain (β, typically 100–500), so a phototransistor produces far more current per photon than a bare photodiode — much more sensitive, though slower. It's the detector of choice when you need a strong signal and don't need blazing speed, which is exactly the situation inside an optoisolator (next tab).

One junction, two jobs. Forward-biased, a PN junction in the right material emits light (LED). Reverse-biased or unbiased, the same junction absorbs light and makes current (photodiode, solar cell). Add transistor gain and you get a phototransistor. The entire detector family is the LED's physics played in reverse — which is why an LED can even be used (poorly) as a light sensor in a pinch.
Solar Cell I–V & Power Curve

Sweep across a solar cell's operating points. The current stays near its light-set value until voltage approaches ~0.5 V, then collapses. Power = V×I peaks at the "knee" — the maximum power point. Slide the illumination to scale the whole curve.

Illumination 80%
A single silicon solar cell produces roughly what open-circuit voltage in full sun, and how do you raise the panel's voltage?

Chapter 7: Optoisolators

Here is a problem the LED and the phototransistor solve together beautifully. Suppose a delicate 3.3 V microcontroller needs to switch a noisy 240 V mains load. Wire them directly and a voltage spike on the mains side could destroy your micro — or you. You need them to communicate without sharing any electrical connection. The answer is to send the signal as light across a gap.

An optoisolator (optocoupler) packs an LED facing a phototransistor inside one opaque case. The micro drives the LED; the LED's light hits the phototransistor; the phototransistor switches the high-voltage circuit. The two sides never touch — the only bridge is a beam of light across a few millimeters of clear epoxy. Isolation voltages of several thousand volts are routine. A surge on the output side stops dead at the gap.

Current Transfer Ratio

The key spec is how much output (collector) current you get per unit of input (LED) current. That's the Current Transfer Ratio:

CTR (%) = (Icollector / ILED) × 100

A typical optoisolator has CTR around 50–100%. Worked example: drive the LED at ILED = 10 mA through a part with CTR = 60%. The phototransistor can sink up to IC = 0.60×10 = 6 mA. If your output load needs more than that, you either raise the LED current or pick a higher-CTR part (or one with a Darlington output stage, where CTR can exceed several hundred percent).

Don't forget: the LED inside still needs a current-limiting resistor on the input side, sized with the same Rs = (Vin−Vf)/I formula from Chapter 3 (its Vf is usually ~1.2–1.4 V, often infrared). Everything you learned about driving LEDs applies to the input of an optoisolator.

Light is a one-way, galvanically-isolated wire. Because nothing conducts across the gap, the input and output can sit at wildly different voltages — ground loops are broken, mains is kept off your logic, and noise can't couple through. Specialized optocouplers go further: a zero-cross opto-triac (like the MOC3041) waits for the AC waveform to pass through zero before switching, so it turns mains loads on and off without generating electrical noise spikes.
Optoisolator: Light Across the Gap

Left side (input): an LED driven at ILED. Right side (output): a phototransistor, fully isolated. Adjust the LED current and the CTR; the output collector current and the light beam scale accordingly. Note the two sides share no wire.

LED current ILED 10.0 mA
CTR 60%
What is the purpose of an optoisolator (optocoupler)?

Chapter 8: Connections & Summary

Optoelectronics is one idea seen from both ends. An electron crossing a band gap either emits a photon (LED, laser diode) or is freed by one (photoresistor, photodiode, solar cell, phototransistor). The photon's color is its energy, E = hc/λ, and that energy equals the band gap, which equals (roughly) the forward voltage. Drive LEDs by current, sense light by turning current or resistance into voltage, and bridge two circuits with light alone.

One more emitter: the laser diode

A laser diode is an LED with a built-in optical cavity (mirrored facets) that forces the emitted light to be coherent, monochromatic, and tightly collimated. They read your discs and carry the internet: a CD laser is ~780 nm infrared, a DVD laser ~650 nm red, Blu-ray ~405 nm violet (shorter λ → smaller spot → more data per disc). Paired with photodiodes and glass optical fiber (single-mode fiber has an 8–10 μm core), laser diodes send light pulses down hair-thin glass for kilometers — the electron-photon bridge stretched across continents.

The equation cheat-sheet

QuantityFormulaNotes
LED series resistorRs = (Vin − Vf) / ILEDRound up to next standard value; target I ≈ 20 mA
Series LED stringRs = (Vin − n·Vf) / ILEDKeep n·Vf < ~80% of Vin
Resistor powerP = I2·R = VR·IStay under the resistor's wattage rating
Photon energyE = h·f = h·c / λh = 6.63×10−34 J·s, c = 3.0×108 m/s
Frequency / wavelengthλ = c / fShorter λ → higher energy → higher Vf
Photoresistor dividerVout = Vin·R2/(R1+R2)LDR position sets light- vs dark-activated
Optoisolator CTRCTR(%) = (IC/ILED)×100Typical 50–100%; Darlington output >100%

Forward voltage by color (quick reference)

Colorλ (nm)Typical Vf
Infrared880–940~1.2–1.4 V
Red650–660~1.7–1.8 V
Yellow / Orange590–610~2.0–2.1 V
Green565~2.0–2.1 V
Blue470~3.2–3.4 V
Whitebroadband~3.4–3.6 V
The single sentence to remember. An LED is a current device whose forward voltage is its band gap is its color; run that junction backward and light makes the current instead. Everything in this chapter — resistor sizing, displays, light sensors, solar cells, optoisolators — is a corollary of that one sentence.

Where this connects in the rest of the book

"Same junction, run forward to make light, run backward to make current."
— The whole of optoelectronics in one line

You can now size any LED resistor, read a color off a forward voltage, drive a display, sense light, and isolate two circuits with a beam. Next, we widen the lens from light to every physical quantity — temperature, force, motion — in Chapter 6.

The photon energy of light emitted (or absorbed) by a junction is given by which relation?
← Ch 4: Semiconductors Ch 6: Sensors →