esp8266book

View the Project on GitHub zacharski/esp8266book

Experiment 6: Finally some Music1

In this experiment we are going to learn how to make a speaker or buzzer click. Now a click may not sound like much :-) but when we put clicks together we can make more interesting sounds. For example, if we have 440 clicks in a second we have the note ‘A’. If we have 3 short periods of it clicking at 392 clicks per second followed by a period of it clicking at 261 clicks per second we have the opening four notes of Beethoven’s Fifth Symphony (albeit in a musical greeting card quality). Let’s get clicking.

Parts Needed

You will need:

Hardware Hookup

Link to larger image

Link to larger image

The basic code

Here is a link to the code

Demo the code! 15xp

Question

How do you get the song to play exactly once?

Remix. 70-125xp

Can you write code to have the buzzer play a recognizable (and correct) tune that spans an octave and a half? (see frequencies for the equal temperament scale). 35-60xp depending on quality/quantity.

1: Tutorials are CC BY-SA 4.0. Original page at Sparkfun Inventor’s Kit for Photon. This slight remix by Ron Zacharski