Curriculum
Course: Ultrasonic Sensor Basics
Login
Text lesson

Working Principle

Working Principle

  1. Arduino sends a 10 μs pulse to the TRIG pin.
  2. HC-SR04 emits ultrasonic sound waves.
  3. Sound waves hit an object and return as an echo.
  4. The ECHO pin stays HIGH for the travel time.
  5. Arduino measures this time.
  6. Distance is calculated using:

Distance=Duration×0.0342Distance = \frac{Duration \times 0.034}{2}

  1. If the distance is less than or equal to 10 cm:
    • LED turns ON.
  2. Otherwise:
    • LED turns OFF.

Expected Output

Distance LED Status
5 cm ON
8 cm ON
10 cm ON
15 cm OFF
25 cm OFF
×
×

Cart