Arduino for Beginners · Sensors, I2C/SPI buses and the final project
Digital sensors: ultrasonic rangefinder and motion sensor
Sensors, I2C/SPI buses and the final project
Introduction
The two most popular sensors in Arduino projects: the HC-SR04 ultrasonic rangefinder (measures distance by echolocation) and the PIR HC-SR501 motion sensor (detects motion from changes in infrared radiation). This lesson dissects their pins, operating principle, the distance formula (speed of sound 343 m/s), the pulseIn() function, PIR potentiometer tuning, and common pitfalls: missing common ground, integer division, and the measurement dead zone.