Actions

KAmod Photo Interrupter Sensor

From Kamamilabs.com - Wiki

Description

KAmod Photo Interrupter Sensor - Slotted Optical Interrupter Module
The KAmod Photo Interrupter Sensor module is a precise IR optical sensor designed for object presence detection, pulse counting, and building incremental encoders. The sensing element operates in the infrared spectrum, which effectively eliminates the influence of external (visible) light on the stability of the sensor's operation. The device features an integrated Schmitt trigger, ensuring a clean, chatter-free digital output signal. Additionally, the board includes an onboard LED indicating the sensor's operating status – when the light beam is interrupted, the LED changes state, and a low state (GND) appears on the digital output.


Technical Specification & Key Features

  • Slot width: 6 mm
  • Compatibility with 3.3 V systems (e.g., Raspberry Pi Pico, STM32) and 5 V systems (e.g., Arduino).
  • Power supply: 3.3 - 5V DC
  • JST XH-2.5 3-pin right-angle connector
  • Mounting holes with a diameter of 3 mm
  • Dimensions: 26.8 × 15 × 18.7 mm



Kit Contents

Code Description
KAmod Photo Interrupter Sensor
  • Assembled and tested module
  • JST XH 2.54 mm to BLT 2.54 mm 3-pin male cable, 200 mm




Schematic


Pinout Description

Pin Name Type Description
1 VCC Power Module supply voltage (3.3 V to 5 V)
2 GND Power Ground (GND)
3 OUT / DO Output Digital signal:
  • High state (H): infrared beam uninterrupted
  • Low state (L): object is in the slot (beam interrupted)



Connection Example and Test Code

The following example demonstrates how to connect the module to a development platform and perform a basic sensor state reading.

Connection Diagram
Sensor Module Platform (e.g., Arduino / RPi Pico)
VCC 3.3V / 5V
GND GND
OUT Digital pin (e.g., D2)



Test Code (Arduino IDE)

The following program configures the pin as an input with an internal pull-up resistor, monitors the sensor state in real-time, and sends messages to the Serial Monitor.

Source code for Arduino UNO:

/* Slotted optical interrupter module test   */

const int SENSOR_PIN = 2; // Sensor DOUT pin connected to Arduino pin D2
const int LED_PIN = 13;   // Built-in LED pin on the Arduino UNO board

void setup() {
  // Configure the sensor pin as an input with an internal pull-up resistor.
  // Configure the built-in LED pin as an output.
  pinMode(LED_PIN, OUTPUT);
  
  // Initialize serial communication at 9600 bps
  Serial.begin(9600);
  Serial.println("--- KAmod Photo Interrupter Sensor Test Started ---");
}

void loop() {
  // Read the digital state from the sensor
  int sensorState = digitalRead(SENSOR_PIN);

  // Module operating logic:
  // LOW (0)  -> IR beam uninterrupted (slot clear). Module LED is ON.
  // HIGH (1) -> IR beam interrupted (obstacle detected). Module LED is OFF.
  
  if (sensorState == LOW) {
    // No obstacle
    digitalWrite(LED_PIN, LOW);   // Turn off the built-in Arduino LED
    Serial.println("Status: OK (Slot clear)");
  } 
  else {
    // Object detected in the slot
    digitalWrite(LED_PIN, HIGH);  // Turn on the built-in Arduino LED (detection signaling)
    Serial.println("Status: BLOCKED (Obstacle detected!)");
  }
  delay(100);
}

Functional Verification Guide

  1. Connect the module to the Arduino according to the connection table.
  2. Open the Serial Monitor in the Arduino IDE (Ctrl+Shift+M) and set the baud rate to 9600 baud.
  3. When the slot is empty, you should see the message `Status: OK (Slot clear)` in the window.
  4. Insert an opaque object (e.g., a piece of plastic, cardboard, or an encoder disc) into the slot. The message should instantly change to `Status: BLOCKED (Obstacle detected!)`, and the built-in Arduino LED (L) should light up.