Hi,
I am making a self driving car.I am using the Ultrasonic sensor(HC-Sr04) for this purpose.I have made all the connections correctly.I am using Arduino Uno for this purpose.I programmed it with NewPing library,but its not working.Can anyone provide me with the code for this.
Thank You 
Hi,
Welcome to the forum.
I programmed it with NewPing library,but its not working. Can anyone provide me with the code for this.
Can you post your code please and also a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easy to read.
Thanks.. Tom.. 
// ---------------------------------------------------------------------------
// Example NewPing library sketch that does a ping about 20 times per second.
// ---------------------------------------------------------------------------
#include <NewPing.h>
#define TRIGGER_PINÂ 12Â // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PINÂ Â 11Â // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 50 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
void setup() {
 Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
 pinMode(2, OUTPUT);
 pinMode(3, OUTPUT);
 pinMode(4, OUTPUT);
 pinMode(5, OUTPUT);
Â
}
void M1_REV()
{
 digitalWrite(2, LOW);
 digitalWrite(3, HIGH);
}
void M1_FWD()
{
 digitalWrite(2, HIGH);
 digitalWrite(3, LOW);
}
void M2_REV()
{
 digitalWrite(4, LOW);
 digitalWrite(5, HIGH);
}
void M2_FWD()
{
 digitalWrite(4, HIGH);
 digitalWrite(5, LOW);
}
void STOP_M1()
{
 digitalWrite(2, LOW);
 digitalWrite(3, LOW);
Â
}
void STOP_M2()
{
 digitalWrite(4, LOW);
 digitalWrite(5, LOW);
}
void left()
{
 M1_REV();
 M2_FWD();
 delay(1800);
 }
 void right()
{
 M1_FWD();
 M2_REV();
 delay(1800);
Â
 }
void loop() {
Â
 delay(50);          // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
 Serial.print("Ping: ");
 Serial.print(sonar.ping_cm()); // Send ping, get distance in cm and print result (0 = outside set distance range)
 Serial.println("cm");
 if(sonar.ping_cm()<30)
 {
  STOP_M1();
  STOP_M2();
 }
 else
 {
  M1_FWD();
  M2_FWD();
 }
}
So what is it doing?
What gets printed on the serial monitor?