

The KY-010 Photo Interrupter, manufactured by ESP32, is an optoelectronic device designed to detect the presence or absence of an object by interrupting a beam of light. It consists of an infrared LED and a phototransistor housed in a U-shaped structure. When an object passes through the gap, it blocks the light beam, causing a change in the output signal.
This component is widely used in applications such as:








The KY-010 Photo Interrupter is a compact and reliable device with the following specifications:
| Parameter | Value | 
|---|---|
| Manufacturer | ESP32 | 
| Part ID | KY-010 | 
| Operating Voltage | 3.3V to 5V | 
| Output Type | Digital (High/Low) | 
| Gap Width | 5mm | 
| LED Wavelength | Infrared (typically 940nm) | 
| Operating Temperature | -25°C to +85°C | 
| Dimensions | 10mm x 10mm x 5mm | 
The KY-010 has three pins, as described in the table below:
| Pin | Name | Description | 
|---|---|---|
| 1 | Signal (S) | Digital output signal. Goes LOW when the light beam is interrupted. | 
| 2 | VCC | Power supply pin. Connect to 3.3V or 5V. | 
| 3 | GND | Ground pin. Connect to the ground of the circuit. | 
Wiring the KY-010:
VCC pin to a 3.3V or 5V power source.GND pin to the ground of your circuit.Signal pin to a digital input pin on your microcontroller (e.g., Arduino UNO).Circuit Example:
Signal pin if necessary to ensure a stable HIGH signal when the beam is not interrupted.Arduino UNO Example Code: Below is an example code snippet to read the KY-010's output using an Arduino UNO:
// Define the pin connected to the KY-010 Signal pin
const int photoInterrupterPin = 2;
void setup() {
  pinMode(photoInterrupterPin, INPUT); // Set the pin as input
  Serial.begin(9600); // Initialize serial communication for debugging
}
void loop() {
  int sensorState = digitalRead(photoInterrupterPin); // Read the sensor state
  if (sensorState == LOW) {
    // The light beam is interrupted
    Serial.println("Object detected!");
  } else {
    // The light beam is not interrupted
    Serial.println("No object detected.");
  }
  delay(100); // Add a small delay to avoid spamming the serial monitor
}
The KY-010 does not detect objects:
VCC and GND pins are properly connected.Unstable or noisy output signal:
Signal pin.False detections or missed objects:
Q: Can the KY-010 be used with a 3.3V microcontroller like the ESP32?
A: Yes, the KY-010 is compatible with both 3.3V and 5V systems, making it suitable for use with the ESP32.
Q: What is the maximum object thickness the KY-010 can detect?
A: The KY-010 has a gap width of 5mm, so it can detect objects up to approximately 4.5mm thick.
Q: Can the KY-010 detect transparent objects?
A: Transparent objects may not block enough infrared light to trigger the sensor. For such applications, consider using a different type of sensor.
Q: How can I increase the detection range of the KY-010?
A: The detection range is fixed by the gap width and the sensitivity of the phototransistor. For larger detection ranges, consider using a reflective optical sensor instead.
By following this documentation, you can effectively integrate the KY-010 Photo Interrupter into your projects and troubleshoot any issues that arise.