Arduino Wiring & Test

This example will use the Teensy 3.6 and will read an MP3 file off of an SD card and play it back through the onboard 2-channel DAC. The audio output goes through an impedance matching series resistor and an RC low pass filter to remove the DC offset.

Wiring

  • DAC0- connect DAC0 on the teensy to the positive (longer) lead of a 10uF electrolytic capacitor through a 68ohm resistor. The resistor value isn't critical, try to pick something in the 47 - 100 ohm range. Connect the negative (shorter) lead of the electrolytic capacitor to the left lead of the headphone jack. Connect a 10k resistor from the left lead of the headphone jack to AGND on the teensy.
  • DAC1 - connect DAC1 on the teensy to the positive (longer) lead of a 10uF electrolytic capacitor through a 68ohm resistor. Again, the resistor value isn't critical, try to pick something in the 47 - 100 ohm range. Connect the negative (shorter) lead of the electrolytic capacitor to the right lead of the headphone jack. Connect a 10k resistor from the right lead of the headphone jack to AGND on the teensy.
  • Connect the ground (center) pin on the headphone jack to AGND on the teensy.

Loading the SD card

Rename your MP3 file test.mp3 and load it onto a standard formatted microSD card.

Insert the microSD card into the SD slot on the teensy.

Download the Library 

To begin playing files, you will need to download Adafruit_MP3 from our github repository. You can do that by visiting the github repo and manually downloading or, easier, just click this button to download the zip

Rename the uncompressed folder Adafruit_MP3 and check that the Adafruit_MP3 folder contains Adafruit_MP3 .cpp and Adafruit_MP3 .h

Place the Adafruit_MP3 library folder your arduinosketchfolder/libraries/ folder. 
You may need to create the libraries subfolder if its your first library. Restart the IDE.

We also have a great tutorial on Arduino library installation at:
http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use

Load Play from SD example

Open File->Examples->Adafruit_MP3->play_from_SD and upload to your Teensy. Open up the serial console and make sure it is able to read the SD card.

You should hear the file play through whatever is plugged into the 3.5mm jack.

NOTE: if playback of your file is choppy, try a different file with a lower bitrate.

Adjusting the Volume

The DAC on the Teensy and Feather/Metro M4 has 12 bit resolution. This means the output can have 4096 different values ranging from 0 (ground) to 4095 (3.3V). In this simple example we can raise or lower the volume by changing the mapping of the value that is written to the DAC.

Change VOLUME_MAX in the sketch to a desired value between 0 (inaudible) and 4095 (very loud).

Last updated on 2017-11-09 at 04.29.54 PM Published on 2017-11-09 at 04.34.51 PM