PROTO D21G audio playback

using the DAC output to play sound

Tom

The Industruino D21G MCU runs at 48MHz and has a DAC output, which enables it to create a sound output. Arduino provides this example of a simple audio player, with the AudioZero library available in the IDE library manager.

A short video of the demo project is shown below:

A0 vs DAC0

On the Arduino boards, the DAC is on pin A0 but this pin is not defined in the Industruino D21G, which uses DAC0 as pin name for this output. The AudioZero library uses the A0 name, so we have to add a line to the AudioZero.h library file:

#define A0 DAC0 // added for Industruino D21G

This line makes sure the library uses DAC0 instead of A0.

The above tutorial uses an LM386 as audio amplifier, but i used a simple cheap class D stereo amp (PAM8403) that does not even require a DC filtering capacitor; the DAC output can be directly connected to one of the amp's input channels. It can be powered from the PROTO's 5V and GND terminals, so only 3 wires are required.

SD card

We use the SD card slot in the Industruino Ethernet module. As we're not using the Ethernet functionality, we need to make sure to pull the SPI chip select lines of the Ethernet and FRAM high to avoid interference.

The sound file needs to be of a certain format: 8-bit unsigned PCM mono. I generated a file that with this online converter.

Below the code as modified from the above library example. The original did not have the AudioZero.end() so there was a lot of noise after the file stopped playing.