Play The Mexican Hat Dance on a piezo buzzer! Here's a quick demo:
A simplified version of the melody in scored in this [GuitarPro](./assets/Jarabe Tapatío simple melody.gpx) file. It is the basis of the song played by the sketch.
The signal from the Arduino can be directly fed to a piezo, however this doesn't result in a very loud sound.
This circuit uses an LM 386 Low Voltage Audio Power Amplifier as a simple way to amplify the AC signal. Given that we are only interested in the alternating signal, the amplifier input and output signals are isolated with capacitors. The LM 386 is used in the default configuration, which results in a relatively low gain (x20) but that is sufficient for our purposes here.
- LM 386 datasheet
- Based on the Arduino Tone example
- Enhanced with ideas from 9.2 Playing a Simple Melody in the Arduino Cookbook