Missing Ping Library Among Other Things in Code PLEASE HELP

I was trying to build a Theremine using this http://www.instructables.com/id/Theremin-Toy/?ALLSTEPS instructable - the code has an error compiling and I believe its because its missing an "include’ for a ping library for a sonar sensor - there are many ping libraries out there - does anyone recognize the functions in the code that could be specific to a single library?

Here is the code:

#include <Tone.h>
Tone tone1;
//our array of note frequencies
int note[] = {
65,69,73,78,82,87,93,98,104,110,
117,123,131,139,147,156,165,175,185,196,
208,220,233,247,262,277,294,311,330,349,
370,392,415,440,466,494,523,554,587,622,
659,698,740,784,831,880,932,988,1047,1109,
1175,1245,1319,1397,1480,1568,1661,1760,1865,1976,
2093,2217,2349,2489,2637,};
int pingPin = 7; //Trig / Echo Y connection here
int tonePin = 8; //Speaker connects here
int dist;
int pingDuration;
#define RED 11
#define GREEN 10
#define BLUE 9
 
#define RED_LONG 59
#define RED_SHORT 40
#define GREEN_LONG 39
#define GREEN_SHORT 20
#define BLUE_LONG 19
#define BLUE_SHORT 3
void setup()
{
tone1.begin(tonePin); //attach tone1 to tonePin
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
 
// uses a common anode RGB LED (so +5v turns them off)
digitalWrite(RED, HIGH);
digitalWrite(GREEN, HIGH);
digitalWrite(BLUE, HIGH);
}
void loop()
{
pingDuration = getPing(); //read the PING)))
dist = TimeTravel(pingDuration); 
if (dist > 3 && dist < 60) //shortest to longest distance
{
tone1.play(note[67 - (dist-1)]);
} else if(tone1.isPlaying()) {
tone1.stop();}
if (dist > RED_LONG || dist <RED_SHORT) {
digitalWrite(RED, HIGH);
} else {
analogWrite(RED, map(dist, RED_LONG, RED_SHORT, 255, 0));
}
if ((dist > GREEN_LONG) || (dist < GREEN_SHORT)) {
digitalWrite(GREEN, HIGH);
} else {
analogWrite(GREEN, map(dist, GREEN_LONG, GREEN_SHORT, 255, 0));
}
if ((dist > BLUE_LONG) || (dist < BLUE_SHORT)) {
digitalWrite(BLUE, HIGH);
} else {
analogWrite(BLUE, map(dist, BLUE_LONG, BLUE_SHORT, 0, 255));}
delay(125);
}
int getPing()
{
//send a 10us pulse to wake up the sonar
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(10);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);
//get the raw value from the sonar, corresponding to the
//actual time of travel of the ultrasound waves
pinMode(pingPin, INPUT);
return pulseIn(pingPin, HIGH); //return this value
}
int TimeTravel(int microseconds)
{
// return the duration divided by 60. 
// with 60 maximum distance away about is about 2 feet
//for a shorter maximum away distance make the number lower
//for a longer maximum away distance make the number higher
return microseconds / 60 ;
}

THANKS!

It would have helped if you posted the error. When I try to compile your program I get

sketch_aug24a:2: error: 'Tone' does not name a type
sketch_aug24a.ino: In function 'void setup()':
sketch_aug24a:28: error: 'tone1' was not declared in this scope
sketch_aug24a.ino: In function 'void loop()':
sketch_aug24a:44: error: 'tone1' was not declared in this scope
sketch_aug24a:45: error: 'tone1' was not declared in this scope

None of the errors has anything to do with ping.

Do you have Tone.h on your system and if so where is it and what is in it ?

Compiles fine for me. You are definitely missing the third-party "Tone" library. Possibly this one:

https://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation

Yeah sorry I forgot - here it is:

C:\Users\Franklin Marquette\Documents\Arduino\libraries\Tone\Tone.cpp: In member function 'void Tone::begin(uint8_t)':
C:\Users\Franklin Marquette\Documents\Arduino\libraries\Tone\Tone.cpp:121: error: 'bitWrite' was not declared in this scope
C:\Users\Franklin Marquette\Documents\Arduino\libraries\Tone\Tone.cpp:123: error: 'digitalPinToPort' was not declared in this scope
C:\Users\Franklin Marquette\Documents\Arduino\libraries\Tone\Tone.cpp:123: error: 'portOutputRegister' was not declared in this scope
C:\Users\Franklin Marquette\Documents\Arduino\libraries\Tone\Tone.cpp:124: error: 'digitalPinToBitMask' was not declared in this scope
C:\Users\Franklin Marquette\Documents\Arduino\libraries\Tone\Tone.cpp: In member function 'void Tone::play(uint16_t, uint32_t)':
C:\Users\Franklin Marquette\Documents\Arduino\libraries\Tone\Tone.cpp:198: error: 'OUTPUT' was not declared in this scope
C:\Users\Franklin Marquette\Documents\Arduino\libraries\Tone\Tone.cpp:198: error: 'pinMode' was not declared in this scope
C:\Users\Franklin Marquette\Documents\Arduino\libraries\Tone\Tone.cpp:294: error: 'bitWrite' was not declared in this scope
C:\Users\Franklin Marquette\Documents\Arduino\libraries\Tone\Tone.cpp: In member function 'void Tone::stop()':
C:\Users\Franklin Marquette\Documents\Arduino\libraries\Tone\Tone.cpp:361: error: 'digitalWrite' was not declared in this scope

And I have the same Tone library as you john -- if I go Sketch--Import Library-- I can see that the Tone Library is installed so that's good

IDE version?

1.0.5

Looks like the Tone library is not fully compatible with Arduino 1.0.x.

In the library file Tone.cpp change this line:

#include <wiring.h>

to:

#include <Arduino.h>

Ok AWESOME - it now compiles and uploads - but after uploading the IDE says this:

avrdude: stk500_getsync(): not in sync: resp=0x00

Is that an issue?

That means the upload failed. Time to check the connections, settings (Board and Port).

Ok thanks a TON - got it working like a charm