Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 9 of 9

Thread: Audio shield wiring

  1. #1
    Junior Member
    Join Date
    May 2022
    Posts
    11

    Audio shield wiring

    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?

  2. #2
    Senior Member houtson's Avatar
    Join Date
    Aug 2015
    Location
    Scotland
    Posts
    254
    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

  3. #3
    Senior Member h4yn0nnym0u5e's Avatar
    Join Date
    Apr 2021
    Location
    Cambridgeshire, UK
    Posts
    737
    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.

  4. #4
    Junior Member
    Join Date
    May 2022
    Posts
    11
    Thanks! Yes I tried one of the examples too. There wasn't any sound there either.

  5. #5
    Junior Member
    Join Date
    May 2022
    Posts
    11
    Quote Originally Posted by h4yn0nnym0u5e View Post
    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.
    Thank you! I'll try connecting those and post back the progress.

  6. #6
    Junior Member
    Join Date
    May 2022
    Posts
    11
    Quote Originally Posted by h4yn0nnym0u5e View Post
    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?

  7. #7
    Senior Member h4yn0nnym0u5e's Avatar
    Join Date
    Apr 2021
    Location
    Cambridgeshire, UK
    Posts
    737
    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.

  8. #8
    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.

  9. #9
    Junior Member
    Join Date
    May 2022
    Posts
    11
    Thanks for pointing that out. I'm sure that's the issue. I'll try that and report back.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •