Back to Sensors & Actuators Series

Photointerrupter (Optical Slot Sensor)

April 10, 2026 Wasil Zafar 7 min read

Photointerrupter deep dive — IR beam-break physics, interrupt-driven counting, RPM measurement, Arduino code, and industrial applications.

Contents

  1. Working Principle
  2. Electrical Characteristics
  3. Interfacing with MCU
  4. Calibration
  5. Code Example
  6. Real-World Applications
  7. Limitations

Working Principle

A photointerrupter (also called an optical slot sensor or opto-interrupter) consists of an infrared LED emitter and a phototransistor detector facing each other across a narrow gap (typically 3–10 mm). When the beam path is clear, the phototransistor conducts; when an opaque object passes through the slot and blocks the beam, the phototransistor turns off. This produces a clean digital HIGH/LOW signal.

Analogy: It’s like a garage door photo-eye safety sensor in miniature — an invisible IR beam crosses a gap, and anything breaking that beam triggers a detection.

Electrical Characteristics

ParameterTypical (e.g., TCPT1300)
EmitterIR LED (~940 nm)
DetectorPhototransistor (NPN)
Supply Voltage3.3–5 V
LED Forward Current20 mA (typical), 50 mA (max)
Slot Width3–10 mm
Response Time~15 µs (rise + fall)
OutputOpen collector (phototransistor)
Operating Temperature−25 to +85 °C

Interfacing with an MCU

The emitter side needs a current-limiting resistor (typically 220 Ω for 5 V / 20 mA). The detector side uses a pull-up resistor (10 kΩ) to VCC — when the beam is blocked, the output goes HIGH; when unblocked, the phototransistor pulls the output LOW (or vice versa, depending on wiring).

Wiring: IR LED anode → 220 Ω → 5 V, cathode → GND. Phototransistor collector → 10 kΩ pull-up to 5 V + MCU input, emitter → GND. Read as digital input: LOW = beam clear, HIGH = beam blocked.

Calibration

  • LED current: Adjust the resistor to set appropriate IR intensity — too low and dust/dirt causes false triggers
  • Schmitt trigger: For noisy signals, use a Schmitt-trigger buffer (74HC14) to clean up edges
  • Interrupt-driven: Use hardware interrupts (attachInterrupt) for precise timing instead of polling

Code Example

/*
 * Photointerrupter Slot Sensor — Arduino
 * Wiring: IR LED: 5V → 220Ω → Anode, Cathode → GND
 *         Detector: Collector → 10k pullup + Pin 2, Emitter → GND
 * Uses interrupt for precise edge detection
 */
#define SENSOR_PIN 2   /* Interrupt-capable pin */

volatile unsigned long pulseCount = 0;
volatile unsigned long lastPulse = 0;

void sensorISR() {
    pulseCount++;
    lastPulse = micros();
}

void setup() {
    Serial.begin(9600);
    pinMode(SENSOR_PIN, INPUT);
    attachInterrupt(digitalPinToInterrupt(SENSOR_PIN),
                    sensorISR, FALLING);
    Serial.println("Photointerrupter Ready");
}

void loop() {
    static unsigned long lastPrint = 0;
    if (millis() - lastPrint >= 1000) {
        lastPrint = millis();
        noInterrupts();
        unsigned long count = pulseCount;
        pulseCount = 0;
        interrupts();

        /* RPM for a single-slot encoder disc */
        float rpm = count * 60.0;
        Serial.print("Pulses/sec: ");
        Serial.print(count);
        Serial.print("  RPM: ");
        Serial.println(rpm, 0);
    }
}

Real-World Applications

Printers, Encoders & Industrial Object Counting

Photointerrupters are found in virtually every inkjet/laser printer (paper edge detection, cartridge position, and encoder disc reading). Industrial conveyors use them for product counting and position detection. In robotics, slotted encoder discs with photointerrupters provide wheel rotation feedback. They also serve as end-stop switches in 3D printers and CNC machines.

PrintersEncoderCountingEnd-Stop

Limitations

  • Line of sight: Requires a clear optical path — dust, dirt, or condensation can block the beam.
  • Fixed gap: The slot width limits the size of objects that can pass through.
  • Ambient IR: Bright sunlight or IR sources can saturate the phototransistor; use a modulated emitter or optical filter.
  • Binary output: Only detects presence/absence — no distance or colour information.