I included the frequencies of the notes (pleasant to be heard) with #defines .
I then defined the value of the BPM ( you can modify it obviously) and according to that I defined the note values
( the most commonly used ones).
With this defines you can easyly play a note with the command "tone" like this:
tone(pin, note, duration)
the delay is important because thanks to that the note doesn't overlap possibly with the successive ones.
(the "1+" is one extra millisecond that i usually put to separate notes but you can avoid it if you prefer the notes to be continuous.
Here is the code:
Step 1: Example: The imperial march
I wrote the code for the first part of the imperial march... so cool !
HERE IS THE CODE:
The Imperial March
and a video that I made: