my ultrasonic sensor hc sr04 giving very erratic reading

Hello everyone.I am trying to make a distance measurement system using hc sr04 ultrasonic sensor and Arduino Diecimila board.But when I am connecting the sensor with arduino it is giving very erratic readings.Even for smaller distance it is showing value of around 150cm(snap is attached).As recommended am using new ping library v1.5 and arduino IDE v1.6.4.Earlier thought it may be due to faulty sensor but even new sensor showing same behaviour.I am totaly confused where the actual problem lies .Can anyone please help me to solve this puzzle.Following is the code that I am using

#include <NewPing.h>
#define TRIGGER_PIN 3
#define ECHO_PIN 2
#define MAX_DISTANCE 200

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

void setup() {
Serial.begin(9600); .
}

void loop() {
delay(1000);
unsigned int uS = sonar.ping();.
Serial.print("Ping: ");
Serial.print(sonar.convert_cm(uS));
Serial.println("cm");
}

Does the Us change based off distance? If it does, and in a linear fashion, you could just use the Us and multiply that by whatever conversion factor works for your sensor. (You'll have to set it up with a fixed known distance, should be easy to work out.

No Us is not changing linearly and there is always uncertainty in distance measured

I tried your code with 1.06 IDE.
Works great.