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

Thread: Audio board and LED pin 13

  1. #1

    Audio board and LED pin 13

    I am running a sketch on a teensy 3.5 with a teensy audio board of the latest version. I am using peak detection to follow the beats in music and to control a stepper motor with accelstepper. Everything is working but i am getting unintended stepper motion even when there is no input signal and no peaks should be detected at all. This motion directly follows the blinking of the onboard LED on the teeensy. I get the same random flickering running the example sketch shown below.

    My question is, what does the LED flashing represent? Pin 13 is connected to the SGTL5000 rx line so it is necessary. Why is the onboard LED pin used for this and what causes it to flicker? When there is input the LED is virtually steady. I have a few more things to test but it would be very helpful to know what this flickering indicates.


    Code:
    /* Stereo peak meter example, assumes Audio adapter but just uses terminal so no more parts required.
    
    This example code is in the public domain
    */
    
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    const int myInput = AUDIO_INPUT_LINEIN;
    // const int myInput = AUDIO_INPUT_MIC;
    
    AudioInputI2S        audioInput;         // audio shield: mic or line-in
    AudioAnalyzePeak     peak_L;
    AudioAnalyzePeak     peak_R;
    AudioOutputI2S       audioOutput;        // audio shield: headphones & line-out
    
    AudioConnection c1(audioInput,0,peak_L,0);
    AudioConnection c2(audioInput,1,peak_R,0);
    AudioConnection c3(audioInput,0,audioOutput,0);
    AudioConnection c4(audioInput,1,audioOutput,1);
    
    AudioControlSGTL5000 audioShield;
    
    
    void setup() {
      AudioMemory(6);
      audioShield.enable();
      audioShield.inputSelect(myInput);
      audioShield.volume(0.5);
      Serial.begin(9600);
    }
    
    // for best effect make your terminal/monitor a minimum of 62 chars wide and as high as you can.
    
    elapsedMillis fps;
    uint8_t cnt=0;
    
    void loop() {
      if(fps > 24) {
        if (peak_L.available() && peak_R.available()) {
          fps=0;
          uint8_t leftPeak=peak_L.read() * 30.0;
          uint8_t rightPeak=peak_R.read() * 30.0;
    
          for(cnt=0;cnt<30-leftPeak;cnt++) {
            Serial.print(" ");
          }
          while(cnt++<30) {
            Serial.print("<");
          }
          Serial.print("||");
          for(cnt=0;cnt<rightPeak;cnt++) {
            Serial.print(">");
          }
          while(cnt++<30) {
            Serial.print(" ");
          }
          Serial.println();
        }
      }
    }

  2. #2
    Senior Member KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    1,977
    Others can answer this better than I can, but here is my quick take.

    Pin 13 is the standard Arduino pin for LEDs, which was adopted by Teensy.

    Most all IO pins on a Teensy can be configured to do different things (up to about 8 different things per pin). Not all pins have that many
    options.

    One of the capabilities of pin 13 is ALT4 (I2S0_RXD0) (An I2S pin)... So it is used receive data from the SGTL5000. And the LED will show the state of this pin (high and low)...

    Side note: it looks like pin 27(ALT6), can be configured to be this same signal. Not sure if the library could be configured to use this pin instead...

  3. #3
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,029
    Quote Originally Posted by KurtE View Post
    Others can answer this better than I can, but here is my quick take.

    Pin 13 is the standard Arduino pin for LEDs, which was adopted by Teensy.

    Most all IO pins on a Teensy can be configured to do different things (up to about 8 different things per pin). Not all pins have that many
    options.

    One of the capabilities of pin 13 is ALT4 (I2S0_RXD0) (An I2S pin)... So it is used receive data from the SGTL5000. And the LED will show the state of this pin (high and low)...

    Side note: it looks like pin 27(ALT6), can be configured to be this same signal. Not sure if the library could be configured to use this pin instead...
    I would add:
    Audio board is hardwired to use Pin13 as I2S0_RXD0 so no alternative is easily available (except cutting some trace and rerouting the data line to alternative pin).
    Note: The LED has no impact on data transfer

  4. #4
    Senior Member KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    1,977
    Quote Originally Posted by WMXZ View Post
    I would add:
    Audio board is hardwired to use Pin13 as I2S0_RXD0 so no alternative is easily available (except cutting some trace and rerouting the data line to alternative pin).
    Note: The LED has no impact on data transfer
    Or simply not connecting pin 13 of the Audio board to the Teensy and then route a wire from pin 13 of Audio board to in this case Pin27 on T3.5... But again not suggest doing this, just side comment about option if you really can not stand seeing the LED blink...

  5. #5
    the light doesn't bother me. it is just the flickering that seemed to sync with the noise and jitter that suggested this might point to the problem. i have since found that it is caused by high frequency noise that can be filtered out.

Posting Permissions

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