Ping sensor help

HI all,

So im new to arduino, and as a beginner project I decided to try building a very simple walker robot, consisting of two servos and a ping sensor and arduino uno rev 3 microcontroller. So as of now I am trying to figure out how to connect the 4 pin ping sensor to the arduino board. The 4 connections are labeled, vcc, trig, echo, gnd. However, I am not quite sure how and where to connect them. Also how would i begin programming it? Any help would be apprectiated

#define Trig_Pin 13
#define Echo_Pin 10

void setup() {
  pinMode(Trig_Pin, OUTPUT);
  pinMode(Echo_Pin, INPUT);

void loop() {
  unsigned long Time;
  digitalWrite(Trig_Pin,HIGH); delayMicroseconds(1000); digitalWrite(Trig_Pin,LOW);
  Time = pulseIn(Echo_Pin, HIGH);

   // The shorter the time, the closer the object.


You can also look at

I thought the Ping sensors use the same pin for trigger and echo?

Caveat: I have never seen a Ping sensor, only going on what gets posted here.

Tim has written a nice pibg lib here -,106043.0.html -

AWOL: I thought the Ping sensors use the same pin for trigger and echo?

I've seen, though not used, sensors with 3, 4 and 5 pins. So I would assume that a 3 pin sensor would use the same pin for trigger and echo. The 4 pin I have played with (with limited success) uses 4 pin, separate trigger and echo. I'm not sure how 5 pin module would be configured.

AWOL, you are right. The Parallax Ping brand ultrasonic sensors only has three pins with a single trigger/echo pin that is labelled "SIG." The other two pins are "5V" and "GND."

Batchi, could you give us a link to the data sheet or at least tell us what brand and model ultrasonic sensor that you are asking about?

P.S. Can a moderator move this to the sensor section of the forum? Batchi might get more replies.

Hi guys,

Thanks for all the help. A little more info.

I got it from Amazon: With this model name: HC-SR04

How would i connect it to the arduino board?

Again, im a complete novice at this and am trying to figure this out


I've never used the HC-SR04, but here's a good link. Most of the following links have step by step instructions. is an excellent resource. Here is a selection of tutorials for your sensor:

and another:,or.r_gc.r_pw.r_qf.,cf.osb&fp=5b390b1cf5252b20&biw=1047&bih=490

Here is one for a fraction of the price. There are others as well.