I CANT USE COMPLY THIS CODE :(

HERE IS MY CODE=WHEN I TRY TO COMPLY THE CODE,IT SAY NEW PING DOES NOT A NAME TYPE
OR IT SAID UNQUALIFIED ID.WHAT DOES IT MEAN? :confused:

#include <NewPing.h>

#define pingSpeed 100 //Ping frequency (in milliseconds), fastest we should ping is about 35ms per sensor

NewPing leftUS(3, 2, 30); // Left UltraSonic sensor; trigger pin, echo pin, maximum distance (in cm)
NewPing rightUS(5, 4, 30); //Right UltraSonic sensor; trigger pin, echo pin, maximum distance (in cm)

int leftDistance = 0;
int rightDistance = 0;
int speaker = 8;
boolean PlayNote = false;
unsigned long leftTimer, rightTimer;

void setup() {
//The ping library handles the pinModes for us, so only variable values are entered here. Tone functions also set the speaker as an output
leftTimer = millis() + pingSpeed; // Left sensor will fire at 100ms (pingSpeed)
rightTimer = leftTimer + (pingSpeed / 2); //Right sensor fires 50ms after the left one. This is to avoid the ultrasonic waves interfering with each other
}

void loop() {
getDistance(); //Jump down to the get distance void
int Pitch = map(rightDistance, 0, 30, 131, 247); //Map the distance value to a pitch range (131-247 or C3-B3)
if(leftDistance != 0){ //If we are triggering the left sensor
tone(speaker, Pitch); //Play the note
}
else{
noTone(speaker); //else.. stop playing the note
}
}

void getDistance() {
if (millis() >= leftTimer) { //If we are allowed to fire the left sensor
leftTimer += pingSpeed; //Add the value of the frequency to the timer
leftDistance = leftUS.ping_in(); //Ping and store that distance
}
if (millis() >= rightTimer) {
rightTimer = leftTimer + (pingSpeed / 2);
rightDistance = rightUS.ping_in();
}
}

Case matters so it's hard to tell what you're trying to write when you SHOUT

Please re-read the posting guidelines.

HERE IS MY CODE=WHEN I TRY TO COMPLY THE CODE,IT SAY NEW PING DOES NOT A NAME TYPE
OR IT SAID UNQUALIFIED ID.WHAT DOES IT MEAN?

Specifically (which is what you should have been), the IDE reports:

sketch_aug17a:5: error: 'NewPing' does not name a type
sketch_aug17a:6: error: 'NewPing' does not name a type
sketch_aug17a.ino: In function 'void getDistance()':
sketch_aug17a:34: error: 'leftUS' was not declared in this scope
sketch_aug17a:38: error: 'rightUS' was not declared in this scope

The first statement is pretty obvious, isn't it? The type NewPing doesn't mean a thing, because you have not downloaded or properly installed the NewPing library.

After doing that, the error messages change:

Binary sketch size: 7,844 bytes (of a 28,672 byte maximum

HERE IS MY CODE=WHEN I TRY TO COMPLY THE CODE ...

Please comply with the posting guidelines.

How to use this forum