Check out the Part 3 of “HOWTO make sounds with Ardunio” and learn to play melody.
Bit-Banging Sound To bit-bang sound we toggle an output pin at the desired frequency. To play a musical note, we need to use specific frequencies and play the sound for a specific amount of time.
Generating the desired frequency big-bang style means figuring out what the period or cycle time of the desired frequency is. This is easy to calculate, it’s