Input capture is used to capture the input signal given to the microcontroller and measures its frequency and pulse width.
pulse
HCSR04 Ultrasonic sensor and STM32
The hcsr04 emits an ultrasound at 40 KHz which, after reflecting from obstacle, bounces back to the module. We can calculate distance by using