Sound

The Huzzah32 has a digital to analog converter to generate a voltage that can be amplified and played through a speaker. Your kit has two amplifiers and speakers, try each and compare how loud they can get and their noise (hiss) levels.

Get a file on the Huzzah32

There are many types of files that store sound data. Most are compressed and require a complicated algorithm to decompress and play in real time. Instead, let's use the .wav file type, which is literally an uncompressed array of voltages that represets the sound, so it is not size effieicnet, but easy for the Huzzah32 to play.

The Huzzah32 has 8MB of extra flash memory where you can store your sound. Playing back at a standard 44kHz and 16bit depth, that would store 90 seconds of sound. So, you can;t store an entire song, but you can store a few short sound clips.

Load the following .wav files using this utility.

Wire up the audio amplifier and speaker

The speaker requires an amplifier to produce loud and clear sound. The I2S amplifier receives the sound from the Huzzah32 digitally, resulting in less scratchy noise from the speaker. Connect the amplifier ground to ground, 5V to 5V, MISO to MISO, and MOSI to MOSI. I have pre-soldered wires onto the speaker. Connect the speaker wires to the amplifier in the green screw terminals.

Image of sound circuit Speaker circuit

Play the sound

It takes several libraries to play the .wav files using I2S.

Solution

Play the sound and use potentiometer volume

Write some code that plays a sound when the IMU is tapped, and read from the pot to set the volume.