Pitches.h compiling error

I used the mega 2560 starter kit and was doing the very first project blink. I followed all the steps and got compiling error for pitches.h file saying the directory does not have it. I tried all different methods and it is not until i searched internet and found that i need to use

#include "pitches.h"

But if i follow the step and include pitches.h file (either unzip or add by myself). the code automatically created

#include <pitches.h>

and this format difference is causing the issue. I wonder why this happens, and if i will be lucky next time and searched the correct answer if following the tutorial will create wrong stuff for me.

Blink doesn't use pitches.h

but toneKeyboard and toneMelody do:

What are you using?

Remove this line.

Thanks Dave and xfpd. You guys are right blink does not need this line. I now realize it is the residue i got from lesson one when learning to install library etc.

But i am still wondering why i got < > format after I included the library but the correct format is " " . Or at least the second format does not cause any compiling error. (I got this hint from another post in the forum. Someone else also got compiling error for his picthes.h file and one answer asked him to change from <> to ""

Any suggestions?

If you have the library file anywhere in your IDE library path, " " will work, but generally the " " are used for local libraries (libraries found in the sketch folder) and < > are used for libraries in the IDE library path.

Hi @huilovepanda1.

When you way "included the library" do you mean you selected a library from Arduino IDE's Sketch > Include Library menu?

If so, you got that format because the angle brackets syntax is the appropriate syntax for use with external libraries. The Sketch > Include Library menu only lists external libraries, so it is correct for it to use the angle brackets syntax in the #include directives it adds to your sketch.

The angle brackets syntax is only incorrect when the library is inside the sketch. As I said above, the Sketch > Include Library feature is only for external libraries, so it is not accurate to make this statement in regards to that feature.

The #include directives using angle brackets syntax which are added by the Sketch > Include Library feature should not cause a compilation error. There are some specific situations that could cause it though:

  • You deleted or uninstalled the external library after the time you used the Sketch > Include Library feature to add the #include directive.
  • The library author explicitly defined the header filenames for use in the #include directives to be added by the feature, and made a mistake in a filename.
  • Your system produces the specific conditions which breaks Arduino IDE's ability to use external libraries due to a bug.

If you want us to determine exactly why the error occurred, please do this:

I'm going to ask you to provide the full verbose output from a compilation.


:red_exclamation_mark: This procedure is not intended to solve the problem. The purpose is to gather more information.


Please do this:

  1. Select File > New Sketch from the Arduino IDE menus.
  2. Select the library from Arduino IDE's Sketch > Include Library menu.
  3. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  4. Check the box next to "Show verbose output during: โ˜ compile" in the "Preferences" dialog.
  5. Click the "OK" button.
    The "Preferences" dialog will close.
  6. Select Sketch > Verify/Compile from the Arduino IDE menus.
  7. Wait for the compilation to fail.
  8. You will see a "Compilation error: ..." notification at the bottom right corner of the Arduino IDE window. Click the "COPY ERROR MESSAGES" button on that notification.
  9. Open a forum reply here by clicking the "Reply" button.
  10. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
  11. Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
    This will paste the compilation output into the code block.
  12. Move the cursor outside of the code block markup before you add any additional text to your reply.
  13. Click the "Reply" button to post the output.

In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here.

Click here for attachment instructions

  1. Open any text editor program.
  2. Paste the copied output into the text editor.
  3. Save the file in .txt format.
  4. Open a forum reply here by clicking the "Reply" button.
  5. Click the "Upload" icon (Upload icon) on the post composer toolbar:

    The "Open" dialog will open.
  6. Select the .txt file you saved from the "Open" dialog.
  7. Click the "Open" button.
    The dialog will close.
  8. Click the "Reply" button to publish the post.

Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.

This is because the person guessed that pitches.h file was bundled inside the sketch used by that person, not in an external library. This is how it is in some of the example sketches included with Arduino IDE such as "toneMelody":

https://docs.arduino.cc/built-in-examples/digital/toneMelody/

(note that the sketch contains a file pitches.h)