IR Sensor
STM32-Experiments Free Updated Sep 22, 2026

IR Sensor

IR Sensor , Detect and Count Obstacles

Introduction

Automatic parking barriers and factory conveyor-belt counters both rely on exactly this kind of sensing, detecting each time an object passes a fixed point and keeping a running count. In this experiment, an infrared obstacle sensor module is wired to the STM32F070RB and configured to trigger an interrupt every time its beam is broken by a nearby object, and each detected obstacle increments a running count printed over UART.

2. Scope

This experiment covers understanding how an infrared obstacle sensor detects nearby objects using reflected light, configuring its digital output as an external interrupt source, and maintaining a running count from within the interrupt callback function. This reuses the interrupt configuration technique in a genuine counting application, rather than a single push-button response.

3. Prerequisite

3.1 Hardware

  • STM32 Nucleo-F070RB development board

  • Infrared obstacle avoidance sensor module, with an onboard comparator and digital output

  • Breadboard and jumper wires

  • Micro-USB cable

  • PC with PuTTY

3.2 Software

  • STM32CubeMX (standalone)

  • STM32CubeIDE

  • ST-LINK USB driver

  • PuTTY, or an equivalent serial terminal application

Community Q&A

0 questions

Ask questions and get answers from our community and staff moderators.

No questions yet — be the first to start the conversation!

Ask a Question

Please log in to ask a question or post a reply.

Login to Participate