THE OBJECTIVE:
for my project, i'd like to install a sonar sensor in front of the car.
once an object (obstacle or wall) detected, then the car stops.
If that is your only objective you can probably do it with much simpler and cheaper solutions. The simplest way, although not as elegant, is to just just a touch switch attached to your front (or rear) bumper. Whenever the car hits an object, the switch will engage and you can use any digital ports to read that information out.
The PING sensor (more generically the ultrasound range sensor) can be used for more sophisticated tasks such as distance measurement, etc...
This code is what I am using for my wifitank, to measure the distance to things in front and behind it, so it won't drive into things.
double ping(int outPin, int inPin) //Get CM to obstacle in front of the sensor
{
long duration;
pinMode(outPin, OUTPUT);
pinMode(inPin, INPUT);
digitalWrite(outPin, LOW);
delayMicroseconds(2);
digitalWrite(outPin, HIGH);
delayMicroseconds(15);
digitalWrite(outPin, LOW);
delayMicroseconds(20);
duration = pulseIn(inPin, HIGH, 10000); //10000 timeout to make sure the loop wont slow down too much
return duration / 29.0 / 2.0;
}