HC-SR04 ultrasonic sensor modules, also commonly called ping sensors, are practically a dime a dozen, with many Asia online retailers selling them in the $2 to $3 dollar range each. While possibly not intended for an end solution or product, these sensors offer a more affordable option for prototyping and application development compared to the original and possibly more well-known ping sensor sold by Parallax, or transducers sold by Maxbotix.
If you intend to do your prototyping with the HC-SR04 module, you may find yourself having to write slightly customized code to drive the HC-SR04, which has one more pin compared to the Parallax ping sensor. This is because the HC-SR04 has separate pins for the trigger and echo function, where the Parallax module combines this functionality into one pin. For example, the Arduino “ping” example sensor sketch was written for the Parallax ping sensor and will not work “out-of-the-box” with the HC-SR04 as it only has provisions in the code for one signal pin.
The Arduino “ping” example sketch works by setting the “pingPin”, which connects to the Parallax “Sig” pin, to an output, sending the pulse to generate the 40kHz sonar ping and then immediately setting the “pingPin” to an input and using the pulseIn() function to wait for the resulting pulse width generated by the time taken for the echo to be received.
For More Details: HC-SR04 Ping Sensor Hardware Mod