[solved] NewPing error, need help adding library??

Hey guys, i’m getting an error. this is my code that I was given.

#include <Servo.h>     //Inclue Servo Library 
#include <NewPing.h>   //Include NewPing Library

Servo leftServo;       //Create Left Servo object
Servo rightServo;      //Create Right Servo object

#define TRIGGER_PIN  6   //Trigger pin of Ultrasonic sensor connected to pin 6
#define ECHO_PIN     7   //Echo pin of Ultrasonic sensor connected to pin 7
#define MAX_DISTANCE 100 //The maximum distance we want the sensor to look for is 1m

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);  //Create Ultrasonic sensor object

unsigned int time;            //Variable to store how long it takes for the ultrasonic wave to come back
int distance;                 //Variable to store the distance calculated from the sensor
int triggerDistance = 30;     //The distance we want the robot to look for a new path
int fDistance;                //Variable to store the distance in front of the robot
int lDistance;                //Variable to store the distance on the left side of the robot
int rDistance;                //Variable to store the distance on the right side of the robot

void setup() 
{ 
  leftServo.attach(9);        //Left servo connected to pin 9
  leftServo.write(90);        //Write the neutral position to that servo
  rightServo.attach(8);       //Right servo connected to pin 8
  rightServo.write(90);       //Write the neutral position to that servo
} 

void loop()
{
  scan();                                //Get the distance retrieved
  fDistance = distance;                  //Set that distance to the front distance
  if(fDistance < triggerDistance){       //If there is something closer than 30cm in front of us
    moveBackward();                      //Move Backward for a second
    delay(1000); 
    moveRight();                         //Turn Right for half a second
    delay(500);
    moveStop();                          //Stop
    scan();                              //Take a reading
    rDistance = distance;                //Store that to the distance on the right side
    moveLeft();
    delay(1000);                         //Turn left for a second
    moveStop();                          //Stop
    scan();                              //Take a reading
    lDistance = distance;                //Store that to the distance on the left side
    if(lDistance < rDistance){           //If the distance on the left is smaller than that of the right
      moveRight();                       //Move right for 200 milliseconds
      delay(200);
      moveForward();                     //Then move forward
    }
    else{
      moveForward();                     //If the left side is larger than the right side move forward
    }
  }
  else{
    moveForward();                       //If there is nothing infront of the robot move forward
  }
}

void scan(){
  time = sonar.ping();                  //Send out a ping and store the time it took for it to come back in the time variable
  distance = time / US_ROUNDTRIP_CM;    //Convert that time into a distance
  if(distance == 0){                    //If no ping was recieved
    distance = 100;                     //Set the distance to max
  }
  delay(10);
}

void moveBackward(){
  rightServo.write(180);
  leftServo.write(0); 
}

void moveForward(){
  rightServo.write(0);
  leftServo.write(180);
}

void moveRight(){
  rightServo.write(0);
  leftServo.write(0);  
}

void moveLeft(){
  rightServo.write(180);
  leftServo.write(180);
}

void moveStop(){
  rightServo.write(90);
  leftServo.write(95); 
}

and this is my error

yoghurt_tub_bot_basic_obstable_avoidance_code:11: error: 'NewPing' does not name a type
yoghurt_tub_bot_basic_obstable_avoidance_code.ino: In function 'void scan()':
yoghurt_tub_bot_basic_obstable_avoidance_code:60: error: 'sonar' was not declared in this scope
yoghurt_tub_bot_basic_obstable_avoidance_code:61: error: 'US_ROUNDTRIP_CM' was not declared in this scope

I believe i’m supposed to add a library, however i’m not sure how to do that. help? which library am i supposed to add and where can i get it?

Saludos, tienes que descargar la libreria y luego proceder a instalarla en la carpeta donde se instalo el IDE del arduino. O puedes ir a la pestaña Sketch y luego agregar libreria. Luego debe reiniciar el IDE.

Perdona mi ingles, estoy usando el traductor de google.

¿Dónde puedo encontrar la biblioteca?

Descargala de
https://code.google.com/p/arduino-new-ping/downloads/list

which library am i supposed to add

Are you serious?

PaulS:

which library am i supposed to add

Are you serious?

i knew which one, but i didnt know how to add it, please don't question my intelligence, as i take offense to it.

I've added the library (i think) and it's still throwing the same errors.

How did you install the library? Was it this way?

Download the zip file from the link posted earlier.

Extract the folder NewPing and save it somewhere temporarily, for example on the desktop.

In the Arduino IDE, click Sketch - Import Library - Add Library.

Select the NewPing folder on desktop and click OK. You should see a success message in the IDE.

Hackscribble:
How did you install the library? Was it this way?

Download the zip file from the link posted earlier.

Extract the folder NewPing and save it somewhere temporarily, for example on the desktop.

In the Arduino IDE, click Sketch - Import Library - Add Library.

Select the NewPing folder on desktop and click OK. You should see a success message in the IDE.

actually i got it to work, i was adding it to the wrong location