Point a remote at any TV made since the 1980s, press a button, watch a channel change. The mechanism: a single infrared LED on the remote flashes in a precise pattern; a receiver on the TV decodes it. The pattern is so well standardised that NEC's 1986 protocol still wins.

Why infrared, why 38 kHz

Infrared light is invisible, ambient-noise-immune (mostly), and easy to generate from a cheap LED. But the room is full of stray IR — sunlight, fluorescent bulbs, hot heaters. To distinguish the remote's signal from background noise, the IR LED isn't just on/off — it's modulated at 38 kHz. The receiver chip has an internal band-pass filter tuned to 38 kHz and only "sees" pulses that come in at that frequency. Background IR is rejected because it's not pulsing.

So when we say "LED on" in a NEC protocol diagram, we really mean "LED pulsing at 38 kHz." When we say "off" we mean genuinely off. The protocol encodes data in the timing of WHEN the 38 kHz carrier is present versus absent.

The NEC frame

A full NEC transmission is:

  1. 9 ms mark — carrier on. The "wake up, here comes data" header.
  2. 4.5 ms space — carrier off. Confirms it's a NEC frame (not a repeat).
  3. 32 data bits — 8-bit address, 8-bit address-inverse, 8-bit command, 8-bit command-inverse. Each bit consists of a 562 µs mark followed by either a 562 µs space (= bit 0) or a 1687 µs space (= bit 1).
  4. 1 stop bit — a 562 µs mark to delimit the end.

The whole frame takes about 67.5 ms. Holding a button down sends a special "repeat" frame every 110 ms (9 ms mark + 2.25 ms space + stop bit) so the TV knows the user is still pressing.

Why this encoding

Using SPACE WIDTH rather than mark width to encode bits is clever: the receiver only needs to detect transitions and time the gap. The 562 µs mark in front of every bit acts as a clock that the receiver can sync to even if its own clock drifts slightly. The "address + ~address" and "command + ~command" doubling is forward error correction — if any bit got corrupted by noise, the inverse pair won't match and the frame is discarded.

It's a textbook example of a noise-tolerant protocol that fits a meaningful payload (256 commands × 256 device addresses = 65,000 possibilities) into a few milliseconds, using a single optical channel. Forty years later, your apartment is full of devices still speaking NEC.