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 🙂