HC-SR04_UltrasonicSensor icon indicating copy to clipboard operation
HC-SR04_UltrasonicSensor copied to clipboard

Arduino example code for the HC-SR04 ultrasonic ranging sensor.

Ultrasonic Sensor - HC-SR04

Ultrasonic Sensor - HC-SR04)

Ultrasonic Sensor HC-SR04 (SEN-15569)

This is the HC-SR04 ultrasonic ranging sensor. This economical sensor provides 2cm to 400cm of non-contact measurement functionality with a ranging accuracy that can reach up to 3mm.

There are only four pins that you need to worry about on the HC-SR04: VCC (Power), Trig (Trigger), Echo (Receive), and GND (Ground).

HC-SR04 data sheet

Repository Contents

  • /Firmware - Arduino example code. Make sure to check the pin definitions and what you are connecting to.

Documentation

  • Hookup Guide - Basic hookup and project example using the ultrasonic sensor. (Note: The example code used in this tutorial is slightly different than the basic example used in this GitHub repo. Make sure to check your pin definitions if you are just using just the ultrasonic sensor.)

Product Versions

  • SEN-15569- Blue ultrasonic sensor w/ crystal
  • SEN-13959- Red ultrasonic sensor w/out crystal

License Information

This product is open source!

Please review the LICENSE.md file for license information.

If you have any questions or concerns on licensing, please contact [email protected].

Distributed as-is; no warranty is given.

  • Your friends at SparkFun.

<COLLABORATION CREDIT>