Hack an HC SR04 to a 3 Pin Sensor





Introduction: Hack an HC SR04 to a 3 Pin Sensor

I hope you all have heard of that expensive-but-awesome parallax ping))) sensor. I cannot buy one of them it blasts my budget into tiny little pieces of debris floating around (30$ i mean). So what do you do? literally hack your problems into pieces. So guys with the hcsr04 if you are like me pondering over the ping))). Follow this hack and get amazed:)

Step 1: Get the Stuff

1x HC SR04 ultrasonic distance sensor

Lot of 22 awg solid core hookup wire



Programming A/B cable.

Now let us begin

Step 2: The Circuit

Connect this circuit.

Step 3: Code

//this is a code for using a 4 pin hc sr04 sensor as a 3 pin ping sensor By robobot3112

#include <NewPing.h>

#define PING_PIN 12 // Arduino pin for both trig and echo

NewPing sonar(PING_PIN, PING_PIN );

void setup() {



void loop() {

delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay

unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).

Serial.print("Ping: ");
Serial.print(uS / US_ROUNDTRIP_CM); // convert time into distance

Serial.println("cm"); }

Step 4: Results

Here are the results.

Let me know any error i shall revise it.

Please vote



  • Epilog Challenge 9

    Epilog Challenge 9
  • Paper Contest 2018

    Paper Contest 2018
  • Pro Tips Challenge

    Pro Tips Challenge

We have a be nice policy.
Please be positive and constructive.




Am doing a project on obstacle detector using Hcsr04 (I need to use it outdoor so going for ultrasonic). Earlier i had DYP-ME007TX which is 3 pin sensor gives out serial output. as i have problem in converting 32 bit serial output to 8 bit, i brought this HC-SR04 , Am using it with AT89S52. I dono where am making mistake.

I gave 5v to vcc, then gnd. later high pulse to trig input and after that no response from echo. Please help me out!

Thanks in advance.

Does the code get uploaded to your microcontroller ? if so; test the hc-sr04 with an arduino or a clone.

ps sorry for the late reply

Yes i completed the project successfully. The thing i missed early was time frame. when the trig pin receives high pulse for 10 us it emits ultrasonic test signals immediately. thus we must be ready right from the 11th microsec to recieve the signal.

good that you where successful.

I'll look into the microcontroller you are using and send you the problem. Sorry for the late reply.

Thanks! And you are always welcome :)

Thanks! And you are always welcome :)

hello sir i want to use two sensors .

but trigger on one hscr04

echo on other ultrasonic sensor .

can u please tell me how to do

Im not sure what you mean, but i think youre trying to integrate two sensors into one.

So, instead of using trig on one an echo on one,

just short the two pins, and connect the wire as shown in the instructable, because integrating the 2 sensors into one is a difficult task.

Best of luck.

first i will say thank you for answering me.

what i am trying to do is transmit on one ultrasonic .receive from another ultrasonic sensor .