HC-SR04 Ultrasonic Distance SensorDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/wokwi/wokwi-docs/llms.txt
Use this file to discover all available pages before exploring further.
Pin names
Voltage supply (5V)
Pulse to start the measurement
Measure the high pulse length to get the distance
Ground
Attributes
Initial distance value, in centimeters
Operation
To start a new distance measurement set the TRIG pin to high for 10uS or more. Then wait until the ECHO pin goes high, and count the time it stays high (pulse length). The length of the ECHO high pulse is proportional to the distance. Use the following table to convert the ECHO pulse length in microseconds into centimeters / inches:| Unit | Distance |
|---|---|
| Centimeters | PulseMicros / 58 |
| Inches | PulseMicros / 148 |