Instructables

How to easily play music with buzzer on arduino (The imperial March - STAR WARS)

Picture of How to easily play music with buzzer on arduino  (The imperial March - STAR WARS)
Hi,I recently designed a sort of "library" in order to make easier to play exact notes on arduino with the buzzer.
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)
eg:
tone(8,LA3,Q);
delay(1+Q);

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:
ARDU NOTES
(http://tny.cz/d1a629c1)
 
Remove these adsRemove these ads by Signing Up

Step 1: Example: The imperial march

Picture of Example: The imperial march
With a lot of effort I did it!
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:

Step 2: Well done !

Picture of Well done !
Now is your turn , make your arduino "whistle" all kinds of songs!
Hope you enjoyed this instructable !
samuraijack3 months ago
AWESOME
alopes81 month ago
AMAZING DUDE!
alopes81 month ago
AMAZING DUDE!
alopes81 month ago
AMAZING DUDE!
audreyobscura4 months ago
Hey that video is set to private, mind making it public?
eserra (author)  audreyobscura4 months ago
done ;) thanks
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!