There are many ways a microcontroller can display its’ output, but they can be categorized into three types, sight, motion and sound. Sight means that the output is visual based, such as LEDs and LCDs. I’ve done many examples on that so today I’m going to step into new territory, sound.
To produce sound, we need a speaker. Normal speakers are overkill in this simple demonstration, so I dug out a computer buzzer from an old Pentium II PC and to my delight, it still works!
It has two leads, positive and negative. On the other end, there’s a pin header where normally it’ll be plugged into a computer motherboard.
To overcome that, I’ve used two jumper cables to connect it to the Arduino. I’ll be using the Uno R3 because these jumper cables can be plugged straight into it. Positive to Digital Pin 8 and negative to Ground.
I wish that I can write my own code to produce a melody but unfortunately, I’m not musically inclined so I used a sample sketch from the Arduino Cookbook.
So, here it is, playing Twinkle Twinkle Little Star