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
| Parameter | Typical (e.g., TCPT1300) |
|---|---|
| Emitter | IR LED (~940 nm) |
| Detector | Phototransistor (NPN) |
| Supply Voltage | 3.3–5 V |
| LED Forward Current | 20 mA (typical), 50 mA (max) |
| Slot Width | 3–10 mm |
| Response Time | ~15 µs (rise + fall) |
| Output | Open 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).
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.
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.