Audio shield wiring

Pkore

Member
I just got the audio shield for the teensy 4.0 and I'm having trouble getting sound out of it. My project requires that I have the shield separate from the teensy so I have them both mounted to a breadboard and I'm trying to wire it up just to the pins on the teensy needed to get sound out of the headphone jack. According to the docs on the I2S interface I need to have pins 7, 20, 21, and 23 connected. I connected these from the teensy to the corresponding pin numbers on the audio shield. I of course have the 3v, 5v and ground connected as well. When I run my code I don't hear anything. My sketch is just an oscillator connected straight to the audio out. Here is the sketch I'm trying to run:

Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioSynthWaveform       waveform1;      //xy=255,276
AudioOutputI2S           i2s1;           //xy=505,274
AudioConnection          patchCord1(waveform1, 0, i2s1, 0);
AudioConnection          patchCord2(waveform1, 0, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=511,326
// GUItool: end automatically generated code


void setup() {
  // put your setup code here, to run once:
  sgtl5000_1.enable();
  sgtl5000_1.volume(0.5);
  waveform1.begin(WAVEFORM_SINE);
  waveform1.amplitude(0.5);
  waveform1.frequency(220);
  waveform1.pulseWidth(0.15);
}

void loop() {
  // put your main code here, to run repeatedly:

}

What am I doing wrong here?
 
Hi @Pkore,

In your sketch you need to give it some audio memory in setup (try AudioMemory(10); ).

In general for hardware testing you'd be better using one of the examples (File>Examples>Audio>HardwareTesting in Arduino) where at least the code is known to work.

Also a picture of your wiring would help (you need to keep the cables fairly short) if it is still not working.

Cheers, Paul
 
You also need the I²C control pins (18 and 19) connected, or the sgtl5000_1 commands won't work. I also seem to recall you need both the Gnd pins wired, not 100% sure about that.
 
You also need the I²C control pins (18 and 19) connected, or the sgtl5000_1 commands won't work. I also seem to recall you need both the Gnd pins wired, not 100% sure about that.

Thanks for the advice! It worked! The only thing now is there's a high pitch squeal when I plug it into my mixer. It sounds fine through my headphones. I'm thinking it's the length of the wires on my breadboard. They're about 1.5 to 2.0 inches. How long should they be? Or is something else going on?
 
Great news it works! Squeal ... not so good. I've used much longer wires (~20cm) for quick tests, but not connecting to anything much. Could be a ground loop or similar: I'm guessing the mixer is grounded via its power supply, and the Teensy / audio / breadboard via your PC or laptop's USB.
 
If you're connecting the audio shield to a mixer, be sure to use the Line Out signals, NOT the headphone jack. The headphone jack ground is not at the same voltage level as the line out ground.
 
Back
Top