Arduino and Ultrasonic PING range finder

hey, just bought Arduino and Ping Range finder and connected them as shown in torturial about PING. And copied the code from the torturial. It is uploading the file perfectly, the arduino is on and I connected the cables right. So what to do? I use Windows7 64 bit =Tutorial.UltrasoundSensor :-?

So what to do?

You tell us what's wrong.

Well the Ping sensor does not give any light or returns anything..

Tell us what tutorial you are talking about, and post your code. Your code is what tells the Ping to start doing something, and checks the Ping sensor's output. If you aren't getting any output, the problem is either in the wiring of the Ping sensor, or in your code.

The tutorial is from and is =Tutorial.UltrasoundSensor

my code is:

const int pingPin = 7;
void setup() {
// initialize serial communication:
void loop()
// establish variables for duration of the ping,
// and the distance result in inches and centimeters:
long duration, inches, cm;
// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
digitalWrite(pingPin, HIGH);
digitalWrite(pingPin, LOW);
// The same pin is used to read the signal from the PING))): a HIGH
// pulse whose duration is the time (in microseconds) from the sending
// of the ping to the reception of its echo off of an object.
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);
// convert the time into a distance
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print("in, ");
long microsecondsToInches(long microseconds)
// According to Parallax’s datasheet for the PING))), there are
// 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
// second). This gives the distance travelled by the ping, outbound
// and return, so we divide by 2 to get the distance of the obstacle.
// See:
return microseconds / 74 / 2;
long microsecondsToCentimeters(long microseconds)
// The speed of sound is 340 m/s or 29 microseconds per centimeter.
// The ping travels out and back, so to find the distance of the
// object we take half of the distance travelled.
return microseconds / 29 / 2;

Did you open the Serial Monitor window?

If so, what is displayed in that window?

If not, why not?

The serial port is COM3, and it is working, the arduino is getting the code but the Ping sensor, does not blick or anything. I dont know where the serial monitor is.

The ping sensor is an ultrasonic (sound) sensor. Of course it doesn't blink.

The Serial Monitor is opened using the rightmost button on the IDE (to the right of the Upload button). Click it after uploading the sketch. A new window opens. That's where Serial.print writes to.

arh okay, I gives me a lot of values in cm and inches, but it does seem to reaction when my hands get close to the sensor.. So I am not sure what that means, does the sensor work then?

If you are getting different values printed, and there is some relationship between the value and the distance to your hand, then, yes, the sensor is working.

yeah, but there is no relations between the distance and the output return.

We're working blind here - you're being vague. If you point the sensor at a wall, say 60cm away, what value do you read back?

sorry for not giving the right information, I am new to this. at 30 cm distance, the return is from 119-135cm, and about the same when it gets closer.. I find it strange, anything else you need to know=

Might want to look at this thread:

Jesse James,

Thank you very much for this chunk of code, you saved me a lot of time.

Jim, K6JMG