Go Down

Topic: Problem with file "pitches.h" in tutorial sketch "Melody". (Read 5 times) previous topic - next topic


Recently I bought an Arduino Uno board (version 3). I am working with Arduino IDE 1.0.4. I am trying to execute the sketch "Melody" (http://arduino.cc/en/Tutorial/Tone). The sketch begins with the statement: #include "pitches.h". In this file "pitches.h" the frequencies of the musical notes are defined by #define statements. In the following program line the array "melody[]" is declared and initialised with some of the contstants defined in "pitches.h". Compiling the sketch results in a number of error messages saying that the compiler does not know these constants. Apparently the statement #include "pitches.h" doesn't work.

I have tried a number of things, but nothing worked:
- Located the file "pitches.h" in the same folder (named "Melody") as "melody.ino". This provides the IDE with a second tab "pitches.h", but didn't work either.
- Located the file "pitches.h" in the folder "libraries".
- Chanched the statement into #include <"pitches.h">
- Tried to change "pitches.h" into a proper library as described here http://arduino.cc/en/Hacking/LibraryTutorial. This is difficult because "pitches.h" has neither variables nor functions. I am not sure I did this the right way.

Hopefully any of you can help me?

Pim Veld.


You can make libraries/pitches/pitches.h

you can also copy and paste all of those constants at the beginning of your melody sketch. Make sure to delete the #include "pitches.h".


Thanks for your reaction.
I understand that I can circumvent the problem by copying the constants at the beginning of the melody sketch. But I should like to know what is wrong with the code in the tutorial-sketch (because I want to learn how this should be done). I tried putting the file pitches.h in a folder pitches in the libraries-folder, but that didn't work either.

Any other idea's?


I followed the directions on that page (copy the sketch, paste the sketch, create a new tab called pitches.h, copy the code, paste the code), and I got this "error" message:
Binary sketch size: 3,396 bytes (of a 30,720 byte maximum)


To PaulS: That's not an error message, that is a normal message after a successful compilation. So, apparently you had no difficulties in making it work. Can you please tell me how you created an new tab, because I can't find the button indicated in the tutorial to make a new tab.

Go Up