.cpp and .h file locations

I'm working on a wall detecting bug bot out of the Arduino Robotics book. It basically closes one of five switches to tell it that it has hit an object Got it working with no problem. As I am still learning, I thought I would put a speaker on it and make it play a sound when one of the switches closed. The file I'm trying to incorporate into my (working) bug bot sketch is the tone example located in the Arduino library, and it uses the 'pitches.h' file. So I put "#include pitches.h" right under the "#include servo.h statement. I then compile to make sure it's finding the pitches.h file, and I get the following, "Bug_bot_Music.cpp:12:21: error: pitches.h: No such file or directory"

Now my questions. There is no bug_bot_music.cpp file. Matter of fact, the original sketch was copied and pasted out of a pdf file, so I don't have a .cpp with this sketch, as far as I know. Am I wrong to assume that a sketch doesn't have to have a .cpp file to compile correctly. And secondly, the pitches.h file is presently located in the library/tone directory, but evidently this new sketch is not finding it. So.....what am I doing wrong and where should I locate my files so the compiler finds them correctly.

As I said, I'm new, so be kind and just tolerate my ignorance.

You'll want to have the pitches.h file in the same directory as your .pde file. The IDE creates a .cpp file out of your .pde file after it adds some things, the location of which can be found when holding shift while compiling (but not uploading).

Also, you'll want to use this syntax:

#include "pitches.h"

You may need to click on the "new tab" icon (top RH corner in the IDE) and make pitches.h the file name. Then paste the contents into the window that appears. Otherwise it may still not know about the file.

JeLC50:
Now my questions. There is no bug_bot_music.cpp file. Matter of fact, the original sketch was copied and pasted out of a pdf file, so I don't have a .cpp with this sketch, as far as I know. Am I wrong to assume that a sketch doesn't have to have a .cpp file to compile correctly. And secondly, the pitches.h file is presently located in the library/tone directory, but evidently this new sketch is not finding it. So.....what am I doing wrong and where should I locate my files so the compiler finds them correctly.

What is the name of your sketch file, including extension?

Then, pitches.h (and pitches.c or pitches.cpp, if existing), need to be in the 'libraries/tone' directory, 'not library/tone' (see the plural?), inside your sketchbook dir.

And, you need to restart the IDE after you have placed a new lib into the libraries directory.