Tips · Sensing

IR tripwire false triggers: ambient light vs modulation

A phototransistor that “just looks for IR” will fire when a cloud moves or a fluorescent ballast flickers. Real tripwires listen for a coded blink, not raw brightness.

Infrared tripwires are a classic first sensing project: LED on one side, detector on the other, break the beam and something happens. The first version almost always works on the workbench at night — and then fails the moment you take it near a window.

What the detector actually sees

An IR phototransistor (or photodiode) responds to photons in a band that overlaps sunlight, halogen lamps, and many classroom LEDs. Ambient light looks like a strong DC (or slowly changing) signal on top of your beam. If your code only checks “is the pin dark?”, a bright room can look like a permanent break — or a shadow can look like a trip.

  • Sunlight — huge IR content; thresholds drift as clouds pass.
  • Fluorescents / cheap LEDs — often flicker at line frequency or PWM rates that alias into your sample loop.
  • Phone cameras / remotes — extra IR sources you did not design for.

Modulation: blink on purpose

The fix used in TV remotes and industrial light curtains is the same idea: drive the emitter at a known frequency (often tens of kHz) instead of leaving it on steadily. The receiver ignores steady ambient and only trusts energy at that blink rate.

Hardware modules (TSOP-style receivers) do the demodulation for you: they output a clean digital “carrier present / not present.” DIY versions can sample fast and check that the beam is still pulsing — not merely bright.

A practical rule for builders

  • Bench check in the dark — prove the geometry and threshold first.
  • Then test under ambient — window light and overheads before you trust the project.
  • Prefer modulated emitter + matching receiver — or accept that a raw ADC threshold will need constant retuning.

That is why sensing packs that need a reliable break-beam treat the emitter as a signal source, not a flashlight. Geometry still matters (aim, distance, stray reflections), but modulation is what keeps the classroom sun from becoming a false alarm.