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

Thread: What pins to assign for MIDI+AUDIO?

  1. #1
    Junior Member
    Join Date
    Mar 2021
    Posts
    12

    What pins to assign for MIDI+AUDIO?

    SORRY ABOUT MY DOUBLE POST I DON'T KNOW HOW TO DELETE THREADS.
    So I'm building a MIDI controller/Standalone Matrix with a Teensy 4.1 and an audio shield, MIDI controls FL Studio and it works, standalone just assigns a different sound to an individual button and plays it through the audio shield's RCA outputs. When trying the standalone portion by itself it works fine but when put together with the rest of my code serial prints the MCU is playing the file but there is no sound coming from it. Is it a pin assignment overlapping each other? Am I missing something on my code? Is it even possible to have both MIDI and standalone together?. Here's my code [I commented certain functions I am working on which are menus for different audio libraries and I am playing the same sound on all buttons for practicity] and attached a picture of my circuit.
    Code:
    #include <LiquidCrystal.h>
    #include <ResponsiveAnalogRead.h>
    #include <Bounce.h>
    #include <ezButton.h>
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    //////////////////////////////////////////////AUDIO PORTS
    AudioPlaySdWav           playWav1;
    AudioOutputI2S           audioOutput;
    AudioConnection          patchCord1(playWav1, 0, audioOutput, 0);
    AudioConnection          patchCord2(playWav1, 1, audioOutput, 1);
    AudioControlSGTL5000     sgtl5000_1;
    //////////////////////////////////////////////SD CARD INPUTS
    #define SDCARD_CS_PIN    BUILTIN_SDCARD
    #define SDCARD_MOSI_PIN  11  // not actually used
    #define SDCARD_SCK_PIN   13  // not actually used
    //////////////////////////////////////////////STANDLAONE MENU
    const int numberOfScreens = 6;
    int currentScreen = 0;
    String screens[numberOfScreens][3] = {{"RAP","OK","NEXT"}, {"R&B","OK","NEXT"}, 
    {"HOUSE","OK","NEXT"},{"TECHNO","OK","NEXT"}, {"MOOMBAHATON","OK","NEXT"}, {"REGGAETON","OK","NEXT"}};
    int parameters[numberOfScreens];
    /////////////////////////////////////////////MIDI CHANNEL SELECT
    const int channel = 0;
    ///////////////////////////////////////////// LCD
    const int rs = 12;
    const int en = 11;
    const int d4 = 9;
    const int d5 = 8;
    const int d6 = 7;
    const int d7 = 6;
    
    LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
    ///////////////////////////////////////////// MENU BUTTONS
    const int ok = 30;
    const int next = 29;
    const int prev = 28;
    
    ezButton button30(ok);
    ezButton button29(next);
    ezButton button28(prev);
    
    int okFlag = 0;
    int backFlag = 0;
    int toggleFlag = 0;
    ///////////////////////////////////////////// ANALOG INPUTS
    const int A_PINS = 12;
    const int ANALOG_PINS[A_PINS] = {A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11};
    const int CCID[A_PINS] = {21, 22, 23, 24, 25, 26, 27, 28, 29 , 30, 31, 32};
    
    byte data [A_PINS];
    byte dataLag[A_PINS];
    
    ResponsiveAnalogRead analog []{
      {ANALOG_PINS[0],true},
      {ANALOG_PINS[1],true},
      {ANALOG_PINS[2],true},
      {ANALOG_PINS[3],true},
      {ANALOG_PINS[4],true},
      {ANALOG_PINS[5],true},
      {ANALOG_PINS[6],true},
      {ANALOG_PINS[7],true},
      {ANALOG_PINS[8],true},
      {ANALOG_PINS[9],true},
      {ANALOG_PINS[10],true},
      {ANALOG_PINS[11],true},  
    };
    ///////////////////////////////////////////// DIGITAL INPUTS
    Bounce button0 = Bounce(0, 5);
    Bounce button1 = Bounce(1, 5);  
    Bounce button2 = Bounce(2, 5);  
    Bounce button3 = Bounce(3, 5);  
    Bounce button4 = Bounce(4, 5);
    Bounce button5 = Bounce(5, 5);  
    Bounce button6 = Bounce(6, 5);  
    Bounce button7 = Bounce(7, 5);  
    Bounce button8 = Bounce(8, 5);
    Bounce button9 = Bounce(9, 5);
    Bounce button10 = Bounce(10, 5);
    Bounce button11 = Bounce(11, 5);
    Bounce button12 = Bounce(12, 5);
    Bounce button13 = Bounce(13, 5);
    Bounce button14 = Bounce(14, 5);
    Bounce button15 = Bounce(15, 5);
    //////////////////////////////// CHANNEL BUTTONS
    const int ch1 = 34;
    const int ch2 = 35;
    const int ch3 = 36;
    const int ch4 = 37;
    
    Bounce button16 = Bounce(16, 5);
    Bounce button17 = Bounce(17, 5); 
    Bounce button18 = Bounce(18, 5);
    Bounce button19 = Bounce(19, 5);
    
    int b16 = 0; 
    int b17 = 0; 
    int b18 = 0; 
    int b19 = 0;
    //////////////////////////////// MULTIPLEXER VARIABLE DECLARATION
    const int s0 = 1; 
    const int s1 = 2; 
    const int s2 = 3; 
    const int s3 = 4;
    
    int bc;
    int b0 = 0; 
    int b1 = 0; 
    int b2 = 0; 
    int b3 = 0; 
    int b4 = 0; 
    int b5 = 0; 
    int b6 = 0; 
    int b7 = 0;
    int b8 = 0; 
    int b9 = 0; 
    int b10 = 0; 
    int b11 = 0; 
    int b12 = 0; 
    int b13 = 0; 
    int b14 = 0; 
    int b15 = 0;
    
    void setup() {
    //////////////////////////////////////////////SD CARD STARTUP
    Serial.begin(9600);
    AudioMemory(8);
    
      SPI.setMOSI(SDCARD_MOSI_PIN);
      SPI.setSCK(SDCARD_SCK_PIN);
      if (!(SD.begin(SDCARD_CS_PIN))) {
        // stop here, but print a message repetitively
        while (1) {
          Serial.println("Unable to access the SD card");
          delay(500);
        }
      }
    
    sgtl5000_1.enable();
    sgtl5000_1.volume(1.0);
    ///////////////////////////////////////////// PIN ASSIGNMENT
      pinMode(34, INPUT_PULLUP);
      pinMode(35, INPUT_PULLUP);
      pinMode(36, INPUT_PULLUP);
      pinMode(37, INPUT_PULLUP);
        
      pinMode(28, INPUT_PULLUP);
      pinMode(29, INPUT_PULLUP);
      pinMode(30, INPUT_PULLUP);
      
      pinMode(1, OUTPUT);
      pinMode(2, OUTPUT);
      pinMode(3, OUTPUT);
      pinMode(4, OUTPUT);
      
      pinMode(5, INPUT_PULLUP);
    ///////////////////////////////////////////// LCD STARTUP
      lcd.begin(16, 2);
      lcd.clear();
      lcd.setCursor(6, 0);
      lcd.print("MIDI");
      lcd.setCursor(3, 1);
      lcd.print("CONTROLLER");
      delay(5000);
      lcd.clear();
        
      lcd.setCursor(0, 0);
      lcd.print("Press OK");
      lcd.setCursor(0, 1);
      lcd.print("For MIDI Mode");
      delay(3000);
      lcd.clear();  
    }
    //////////////////////////////////////////////
    void playFile(const char *filename)
    {
      Serial.print("Playing file: ");
      Serial.println(filename);
      playWav1.play(filename);
      delay(25);
    }
    ///////////////////////////////////////////// MENU SELECTION
    void loop() {
    button30.loop();
      if(button30.isPressed()){
        lcd.clear();
        lcd.setCursor(3, 0);
        lcd.print("MIDI MODE");
        delay(3000);
        lcd.clear();
        okFlag = 1;
      }
      if(okFlag == 1){
        analogPins();
        digitalPins();
        chButtons();
        while (usbMIDI.read()) {
      }
      }
      else if(okFlag == 0)
      {
        delay(50);
        standMatrix();
        //inputAction();
        //parameterChange();
        //printMenu();
      }
    }
    ///////////////////////////////////////////// ANALOG CONTROL
    void analogPins()  {
      for (int i=0; i<A_PINS; i++)
      {
      analog[i].update();
      if(analog[i].hasChanged()){
        data[i] = analog[i].getValue()>>3;
          if(data[i] != dataLag[i]){
            dataLag[i] = data[i];
            usbMIDI.sendControlChange(CCID[i], data[i], channel);
            lcd.clear();
            lcd.setCursor(0, 1);
            lcd.print(CCID[i]);
            lcd.setCursor(3, 1);
            lcd.print(data[i]);
          }
        }
      }
    }
    ///////////////////////////////////////////// DIGITAL MULTIPLEXER CONTROL
    void digitalPins(){
    ///////////////////////////////////////////// C0 ADDRESS
    digitalWrite(s0, LOW);
    digitalWrite(s1, LOW);
    digitalWrite(s2, LOW);
    digitalWrite(s3, LOW);
    delayMicroseconds(50);
    button0.update();
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b0 == LOW){
        b0 = HIGH;
        usbMIDI.sendNoteOn(60, 99, 0);  // 60 = C4    
        lcd.setCursor(12, 1);
        lcd.print("B0");
        }
      }else if (bc == HIGH){
        if(b0 == HIGH){
          b0 = LOW;
          lcd.setCursor(12, 1);
          lcd.print("  ");
        }
      }
    ///////////////////////////////////////////// C1 ADDRESS
    digitalWrite(s0, HIGH);
    digitalWrite(s1, LOW);
    digitalWrite(s2, LOW);
    digitalWrite(s3, LOW);
    delayMicroseconds(50);
    button1.update();
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b1 == LOW){
        b1 = HIGH;
        usbMIDI.sendNoteOn(61, 99, 0);   
        lcd.setCursor(12, 1);
        lcd.print("B1");
        }
      }else if (bc == HIGH){
        if(b1 == HIGH){
          b1 = LOW;
          lcd.setCursor(12, 1);
          lcd.print("  ");
        }
      }
    //////////////////////////////////////////////////// C2 ADDRESS
    digitalWrite(s0, LOW);
    digitalWrite(s1, HIGH);
    digitalWrite(s2, LOW);
    digitalWrite(s3, LOW);
    delayMicroseconds(50);
    button2.update();
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b2 == LOW){
        b2 = HIGH;
        usbMIDI.sendNoteOn(62, 99, 0); 
        lcd.setCursor(12, 1);
        lcd.print("B2");
        }
      }else if (bc == HIGH){
        if(b2 == HIGH){
          b2 = LOW;
          lcd.setCursor(12, 1);
          lcd.print("  ");
        }
      }
    ////////////////////////////////////////////////////// C3 ADDRESS
    digitalWrite(s0, HIGH);
    digitalWrite(s1, HIGH);
    digitalWrite(s2, LOW);
    digitalWrite(s3, LOW);
    delayMicroseconds(50);
    button3.update(); 
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b3 == LOW){
        b3 = HIGH;
        usbMIDI.sendNoteOn(63, 99, 0);     
        lcd.setCursor(12, 1);
        lcd.print("B3");
        }
      }else if (bc == HIGH){
        if(b3 == HIGH){
          b3 = LOW;
          lcd.setCursor(12, 1);
          lcd.print("  ");
        }
      }
    ////////////////////////////////////////////////////// C4 ADDRESS
    digitalWrite(s0, LOW);
    digitalWrite(s1, LOW);
    digitalWrite(s2, HIGH);
    digitalWrite(s3, LOW);
    delayMicroseconds(50);
    button4.update(); 
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b4 == LOW){
        b4 = HIGH;
        usbMIDI.sendNoteOn(64, 99, 0);  
        lcd.setCursor(12, 1);
        lcd.print("B4");
        }
      }else if (bc == HIGH){
        if(b4 == HIGH){
          b4 = LOW;
          lcd.setCursor(12, 1);
          lcd.print("  ");
        }
      }
    ////////////////////////////////////////////////////// C5 ADDRESS
    digitalWrite(s0, HIGH);
    digitalWrite(s1, LOW);
    digitalWrite(s2, HIGH);
    digitalWrite(s3, LOW);
    delayMicroseconds(50);
    button5.update(); 
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b5 == LOW){
        b5 = HIGH;
        usbMIDI.sendNoteOn(65, 99, 0);    
        lcd.setCursor(12, 1);
        lcd.print("B5");
        }
      }else if (bc == HIGH){
        if(b5 == HIGH){
          b5 = LOW;
          lcd.setCursor(12, 1);
          lcd.print("  ");
        }
      }
    ////////////////////////////////////////////////////// C6 ADDRESS
    digitalWrite(s0, LOW);
    digitalWrite(s1, HIGH);
    digitalWrite(s2, HIGH);
    digitalWrite(s3, LOW);
    delayMicroseconds(50);
    button6.update(); 
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b6 == LOW){
        b6 = HIGH;
        usbMIDI.sendNoteOn(66, 99, 0); 
        lcd.setCursor(12, 1);
        lcd.print("B6");
        }
      }else if (bc == HIGH){
        if(b6 == HIGH){
          b6 = LOW;
          lcd.setCursor(12, 1);
          lcd.print("  ");
        }
      }
    ////////////////////////////////////////////////////// C7 ADDRESS
    digitalWrite(s0, HIGH);
    digitalWrite(s1, HIGH);
    digitalWrite(s2, HIGH);
    digitalWrite(s3, LOW);
    delayMicroseconds(50);
    button7.update(); 
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b7 == LOW){
        b7 = HIGH;
        usbMIDI.sendNoteOn(67, 99, 0); 
        lcd.setCursor(12, 1);
        lcd.print("B7");
        }
      }else if (bc == HIGH){
        if(b7 == HIGH){
          b7 = LOW;
          lcd.setCursor(12, 1);
          lcd.print("  ");
        }
      }
    ////////////////////////////////////////////////////// C8 ADDRESS
    digitalWrite(s0, LOW);
    digitalWrite(s1, LOW);
    digitalWrite(s2, LOW);
    digitalWrite(s3, HIGH);
    delayMicroseconds(50);
    button8.update();
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b8 == LOW){
        b8 = HIGH;
        usbMIDI.sendNoteOn(68, 99, 0);
        lcd.setCursor(12, 1);
        lcd.print("B8");
        }
      }else if (bc == HIGH){
        if(b8 == HIGH){
          b8 = LOW;
          lcd.setCursor(12, 1);
          lcd.print("  ");
        }
      }
    ///////////////////////////////////////////// C9 ADDRESS
    digitalWrite(s0, HIGH);
    digitalWrite(s1, LOW);
    digitalWrite(s2, LOW);
    digitalWrite(s3, HIGH);
    delayMicroseconds(50);
    button9.update();
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b9 == LOW){
        b9 = HIGH;
        usbMIDI.sendNoteOn(69, 99, 0);
        lcd.setCursor(12, 1);
        lcd.print("B9");
        }
      }else if (bc == HIGH){
        if(b9 == HIGH){
          b9 = LOW;
          lcd.setCursor(12, 1);
          lcd.print("  ");
        }
      }
    //////////////////////////////////////////////////// C10 ADDRESS
    digitalWrite(s0, LOW);
    digitalWrite(s1, HIGH);
    digitalWrite(s2, LOW);
    digitalWrite(s3, HIGH);
    delayMicroseconds(50);
    button10.update();
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b10 == LOW){
        b10 = HIGH;
        usbMIDI.sendNoteOn(70, 99, 0);
        lcd.setCursor(12, 1);
        lcd.print("B10");
        }
      }else if (bc == HIGH){
        if(b10 == HIGH){
          b10 = LOW;
          lcd.setCursor(12, 1);
          lcd.print("   ");
        }
      }
    ////////////////////////////////////////////////////// C11 ADDRESS
    digitalWrite(s0, HIGH);
    digitalWrite(s1, HIGH);
    digitalWrite(s2, LOW);
    digitalWrite(s3, HIGH);
    delayMicroseconds(50);
    button11.update(); 
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b11 == LOW){
        b11 = HIGH;
        usbMIDI.sendNoteOn(71, 99, 0);
        lcd.setCursor(12, 1);
        lcd.print("B11");
        }
      }else if (bc == HIGH){
        if(b11 == HIGH){
          b11 = LOW;
          lcd.setCursor(12, 1);
          lcd.print("   ");
        }
      }
    ////////////////////////////////////////////////////// C12 ADDRESS
    digitalWrite(s0, LOW);
    digitalWrite(s1, LOW);
    digitalWrite(s2, HIGH);
    digitalWrite(s3, HIGH);
    delayMicroseconds(50);
    button12.update(); 
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b12 == LOW){
        b12 = HIGH;
        usbMIDI.sendNoteOn(72, 99, 0);
        lcd.setCursor(12, 1);
        lcd.print("B12");
        }
      }else if (bc == HIGH){
        if(b12 == HIGH){
          b12 = LOW;
          lcd.setCursor(12, 1);
          lcd.print("   ");
        }
      }
    ////////////////////////////////////////////////////// C13 ADDRESS
    digitalWrite(s0, HIGH);
    digitalWrite(s1, LOW);
    digitalWrite(s2, HIGH);
    digitalWrite(s3, HIGH);
    delayMicroseconds(50);
    button13.update(); 
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b13 == LOW){
        b13 = HIGH;
        usbMIDI.sendNoteOn(73, 99, 0);
        lcd.setCursor(12, 1);
        lcd.print("B13");
        }
      }else if (bc == HIGH){
        if(b13 == HIGH){
          b13 = LOW;
          lcd.setCursor(12, 1);
          lcd.print("   ");
        }
      }
    ////////////////////////////////////////////////////// C14 ADDRESS
    digitalWrite(s0, LOW);
    digitalWrite(s1, HIGH);
    digitalWrite(s2, HIGH);
    digitalWrite(s3, HIGH);
    delayMicroseconds(50);
    button14.update(); 
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b14 == LOW){
        b14 = HIGH;
        usbMIDI.sendNoteOn(74, 99, 0);
        lcd.setCursor(12, 1);
        lcd.print("B14");
        }
      }else if (bc == HIGH){
        if(b14 == HIGH){
          b14 = LOW;
          lcd.setCursor(12, 1);
          lcd.print("   ");
        }
      }
    ////////////////////////////////////////////////////// C15 ADDRESS
    digitalWrite(s0, HIGH);
    digitalWrite(s1, HIGH);
    digitalWrite(s2, HIGH);
    digitalWrite(s3, HIGH);
    delayMicroseconds(50);
    button15.update(); 
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b15 == LOW){
        b15 = HIGH;
        usbMIDI.sendNoteOn(75, 99, 0);
        lcd.setCursor(12, 1);
        lcd.print("B15");
        }
      }else if (bc == HIGH){
        if(b15 == HIGH){
          b15 = LOW;
          lcd.setCursor(12, 1);
          lcd.print("   ");
        }
      }
    }
    ///////////////////////////////////////////// CHANNEL BUTTON CONTROL
    void chButtons(){
    ////////////////////////////////////////////////////// CH1 ADDRESS
      button16.update();
      bc = digitalRead(34);
    if (bc == LOW) {
        if( b16 == LOW){
        b16 = HIGH;
        usbMIDI.sendNoteOn(76, 99, 0);
        lcd.setCursor(7, 1);
        lcd.print("CH1");
        }
      }else if (bc == HIGH){
        if(b16 == HIGH){
          b16 = LOW;
          lcd.setCursor(7, 1);
          lcd.print("   ");
        }
     }
    ///////////////////////////////////////////////////// CH2 ADDRESS
      button17.update();
      bc = digitalRead(35);
    if (bc == LOW) {
        if( b17 == LOW){
        b17 = HIGH;
        usbMIDI.sendNoteOn(77, 99, 0);
        lcd.setCursor(7, 1);
        lcd.print("CH2");
        }
       }else if (bc == HIGH){
        if(b17 == HIGH){
          b17 = LOW;
          lcd.setCursor(7, 1);
          lcd.print("   ");
        }
     }
    ///////////////////////////////////////////////////// CH3 ADDRESS
      button18.update();
      bc = digitalRead(36);
    if (bc == LOW) {
        if( b18 == LOW){
        b18 = HIGH;
        usbMIDI.sendNoteOn(78, 99, 0);
        lcd.setCursor(7, 1);
        lcd.print("CH3");
        }
      }else if (bc == HIGH){
        if(b18 == HIGH){
          b18 = LOW;
          lcd.setCursor(7, 1);
          lcd.print("   ");
        }
     }
    ///////////////////////////////////////////////////// CH4 ADDRESS
      button19.update();
      bc = digitalRead(37);
    if (bc == LOW) {
        if( b19 == LOW){
        b19 = HIGH;
        usbMIDI.sendNoteOn(79, 99, 0);
        lcd.setCursor(7, 1);
        lcd.print("CH4");
        }
      }else if (bc == HIGH){
        if(b19 == HIGH){
          b19 = LOW;
          lcd.setCursor(7, 1);
          lcd.print("   ");
        }
     }
    
    }
    /////////////////////////////////////////////MENU SELECTION
    void inputAction()
    {
      button28.loop();
      if(button28.isPressed()){
        if (currentScreen == 0){
          currentScreen = numberOfScreens-1;
        }else{
          currentScreen--;  
        }
      }
    }
    /////////////////////////////////////////////MENU LOAD
    /*
    void parameterChange()
    {
      button29.loop();
      if(button29.isPressed())
      {
        //parameters[currentScreen] = 1;
        //openLibrary(currentScreen);
        playFile("SOUL.WAV");
      }
    }
    */
    /////////////////////////////////////////////MENU PRINTING
    /*
    void printMenu()
    {
      lcd.clear();
      lcd.print(screens[currentScreen][0]);
      lcd.setCursor(0, 1);
      lcd.print(screens[currentScreen][1]);
      lcd.setCursor(12, 1);
      lcd.print(screens[currentScreen][2]);
    
      lcd.setCursor(8,1);
      lcd.print(parameters[currentScreen]);
    }
    */
    /////////////////////////////////////////////LIBRARY SELECTION
    /*
    void openLibrary(int choice)
    {
      if (choice == 1)
      {
        playFile("SOUL.WAV");
        delay(500);
      }
    }
    */
    /////////////////////////////////////////////
    void standMatrix(){
    ///////////////////////////////////////////// C0 ADDRESS
    digitalWrite(s0, LOW);
    digitalWrite(s1, LOW);
    digitalWrite(s2, LOW);
    digitalWrite(s3, LOW);
    delayMicroseconds(50);
    button0.update();
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b0 == LOW){
        b0 = HIGH;
          playFile("SOUL.WAV");  
        }
      }else if (bc == HIGH){
        if(b0 == HIGH){
          b0 = LOW;
    
        }
      }
    ///////////////////////////////////////////// C1 ADDRESS
    digitalWrite(s0, HIGH);
    digitalWrite(s1, LOW);
    digitalWrite(s2, LOW);
    digitalWrite(s3, LOW);
    delayMicroseconds(50);
    button1.update();
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b1 == LOW){
        b1 = HIGH;
          playFile("SOUL.WAV");  
        }
      }else if (bc == HIGH){
        if(b1 == HIGH){
          b1 = LOW;
    
        }
      }
    //////////////////////////////////////////////////// C2 ADDRESS
    digitalWrite(s0, LOW);
    digitalWrite(s1, HIGH);
    digitalWrite(s2, LOW);
    digitalWrite(s3, LOW);
    delayMicroseconds(50);
    button2.update();
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b2 == LOW){
        b2 = HIGH;
          playFile("SOUL.WAV");  
        }
      }else if (bc == HIGH){
        if(b2 == HIGH){
          b2 = LOW;
    
        }
      }
    ////////////////////////////////////////////////////// C3 ADDRESS
    digitalWrite(s0, HIGH);
    digitalWrite(s1, HIGH);
    digitalWrite(s2, LOW);
    digitalWrite(s3, LOW);
    delayMicroseconds(50);
    button3.update(); 
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b3 == LOW){
        b3 = HIGH;
          playFile("SOUL.WAV");  
        }
      }else if (bc == HIGH){
        if(b3 == HIGH){
          b3 = LOW;
    
        }
      }
    ////////////////////////////////////////////////////// C4 ADDRESS
    digitalWrite(s0, LOW);
    digitalWrite(s1, LOW);
    digitalWrite(s2, HIGH);
    digitalWrite(s3, LOW);
    delayMicroseconds(50);
    button4.update(); 
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b4 == LOW){
        b4 = HIGH;
          playFile("SOUL.WAV"); 
        }
      }else if (bc == HIGH){
        if(b4 == HIGH){
          b4 = LOW;
    
        }
      }
    ////////////////////////////////////////////////////// C5 ADDRESS
    digitalWrite(s0, HIGH);
    digitalWrite(s1, LOW);
    digitalWrite(s2, HIGH);
    digitalWrite(s3, LOW);
    delayMicroseconds(50);
    button5.update(); 
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b5 == LOW){
        b5 = HIGH;
          playFile("SOUL.WAV");  
        }
      }else if (bc == HIGH){
        if(b5 == HIGH){
          b5 = LOW;
    
        }
      }
    ////////////////////////////////////////////////////// C6 ADDRESS
    digitalWrite(s0, LOW);
    digitalWrite(s1, HIGH);
    digitalWrite(s2, HIGH);
    digitalWrite(s3, LOW);
    delayMicroseconds(50);
    button6.update(); 
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b6 == LOW){
        b6 = HIGH;
          playFile("SOUL.WAV");  
        }
      }else if (bc == HIGH){
        if(b6 == HIGH){
          b6 = LOW;
    
        }
      }
    ////////////////////////////////////////////////////// C7 ADDRESS
    digitalWrite(s0, HIGH);
    digitalWrite(s1, HIGH);
    digitalWrite(s2, HIGH);
    digitalWrite(s3, LOW);
    delayMicroseconds(50);
    button7.update(); 
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b7 == LOW){
        b7 = HIGH;
          playFile("SOUL.WAV");  
        }
      }else if (bc == HIGH){
        if(b7 == HIGH){
          b7 = LOW;
    
        }
      }
    ////////////////////////////////////////////////////// C8 ADDRESS
    digitalWrite(s0, LOW);
    digitalWrite(s1, LOW);
    digitalWrite(s2, LOW);
    digitalWrite(s3, HIGH);
    delayMicroseconds(50);
    button8.update();
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b8 == LOW){
        b8 = HIGH;
          playFile("SOUL.WAV");  
        }
      }else if (bc == HIGH){
        if(b8 == HIGH){
          b8 = LOW;
    
        }
      }
    ///////////////////////////////////////////// C9 ADDRESS
    digitalWrite(s0, HIGH);
    digitalWrite(s1, LOW);
    digitalWrite(s2, LOW);
    digitalWrite(s3, HIGH);
    delayMicroseconds(50);
    button9.update();
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b9 == LOW){
        b9 = HIGH;
          playFile("SOUL.WAV");  
        }
      }else if (bc == HIGH){
        if(b9 == HIGH){
          b9 = LOW;
    
        }
      }
    //////////////////////////////////////////////////// C10 ADDRESS
    digitalWrite(s0, LOW);
    digitalWrite(s1, HIGH);
    digitalWrite(s2, LOW);
    digitalWrite(s3, HIGH);
    delayMicroseconds(50);
    button10.update();
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b10 == LOW){
        b10 = HIGH;
          playFile("SOUL.WAV"); 
        }
      }else if (bc == HIGH){
        if(b10 == HIGH){
          b10 = LOW;
    
        }
      }
    ////////////////////////////////////////////////////// C11 ADDRESS
    digitalWrite(s0, HIGH);
    digitalWrite(s1, HIGH);
    digitalWrite(s2, LOW);
    digitalWrite(s3, HIGH);
    delayMicroseconds(50);
    button11.update(); 
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b11 == LOW){
        b11 = HIGH;
          playFile("SOUL.WAV");  
        }
      }else if (bc == HIGH){
        if(b11 == HIGH){
          b11 = LOW;
    
        }
      }
    ////////////////////////////////////////////////////// C12 ADDRESS
    digitalWrite(s0, LOW);
    digitalWrite(s1, LOW);
    digitalWrite(s2, HIGH);
    digitalWrite(s3, HIGH);
    delayMicroseconds(50);
    button12.update(); 
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b12 == LOW){
        b12 = HIGH;
          playFile("SOUL.WAV");  
        }
      }else if (bc == HIGH){
        if(b12 == HIGH){
          b12 = LOW;
    
        }
      }
    ////////////////////////////////////////////////////// C13 ADDRESS
    digitalWrite(s0, HIGH);
    digitalWrite(s1, LOW);
    digitalWrite(s2, HIGH);
    digitalWrite(s3, HIGH);
    delayMicroseconds(50);
    button13.update(); 
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b13 == LOW){
        b13 = HIGH;
          playFile("SOUL.WAV");  
        }
      }else if (bc == HIGH){
        if(b13 == HIGH){
          b13 = LOW;
    
        }
      }
    ////////////////////////////////////////////////////// C14 ADDRESS
    digitalWrite(s0, LOW);
    digitalWrite(s1, HIGH);
    digitalWrite(s2, HIGH);
    digitalWrite(s3, HIGH);
    delayMicroseconds(50);
    button14.update(); 
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b14 == LOW){
        b14 = HIGH;
          playFile("SOUL.WAV");  
        }
      }else if (bc == HIGH){
        if(b14 == HIGH){
          b14 = LOW;
    
        }
      }
    ////////////////////////////////////////////////////// C15 ADDRESS
    digitalWrite(s0, HIGH);
    digitalWrite(s1, HIGH);
    digitalWrite(s2, HIGH);
    digitalWrite(s3, HIGH);
    delayMicroseconds(50);
    button15.update(); 
    bc = digitalRead(5); 
      if (bc == LOW) {
        if( b15 == LOW){
        b15 = HIGH;
          playFile("SOUL.WAV"); 
        }
      }else if (bc == HIGH){
        if(b15 == HIGH){
          b15 = LOW;
    
        }
      }
    }
    Click image for larger version. 

Name:	20210404_192752 (1).jpg 
Views:	26 
Size:	158.3 KB 
ID:	24305
    Last edited by Frank B; 04-06-2021 at 08:31 PM.

  2. #2
    Senior Member houtson's Avatar
    Join Date
    Aug 2015
    Location
    Scotland
    Posts
    173
    Hi,

    I didn't review in detail so may not have understood the problem but it looks like you are using pins reserved for the audio board for other input

    A number of pins are not shareable for other inputs - check out the table here:
    https://www.pjrc.com/store/teensy3_audio.html

    cheers, Paul

  3. #3
    Junior Member
    Join Date
    Mar 2021
    Posts
    12
    Quote Originally Posted by houtson View Post
    Hi,

    I didn't review in detail so may not have understood the problem but it looks like you are using pins reserved for the audio board for other input

    A number of pins are not shareable for other inputs - check out the table here:
    https://www.pjrc.com/store/teensy3_audio.html

    cheers, Paul
    I also tried the WavFilePLayer code to troubleshoot but still no audio, the sd card is being read no problem. I tried the LINE OUT pin pairs separately and nothing, also used the AUX input without any audio either.
    I forgot to mention that the first time it worked the AUX audio sounded like an echo from far away and the LINE OUT took some wiring positioning to make it work, then I updated the code and the audio completely stopped playing for all the codes I uploaded to the teensy

  4. #4
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    8,289
    again, you use pins that are used by the audio board.

  5. #5
    Junior Member
    Join Date
    Mar 2021
    Posts
    12
    Quote Originally Posted by Frank B View Post
    again, you use pins that are used by the audio board.

    In my previous reply I mentioned I used the WavFilePlayer code which doesn't assign any pins of the teensy except for the ones of the SD card reader, it reads the file but no sound

  6. #6
    Senior Member
    Join Date
    Apr 2020
    Location
    DFW area in Texas
    Posts
    247
    Quote Originally Posted by DeMoeP View Post
    In my previous reply I mentioned I used the WavFilePlayer code which doesn't assign any pins of the teensy except for the ones of the SD card reader, it reads the file but no sound
    @DeMoeP:

    Did you try connecting *only* the Teensy & the Audio Adapter together - with absolutely no other hardware ?? Running the WaveFilePlayer code with that simple setup would be a useful test. Any additional hardware (especially if it is sharing pins with those used by the Audio Adapter - I think that is what Frank B is referring to) only complicates the troubleshooting unnecessarily.

    Mark J Culross
    KD5RXT

  7. #7
    Junior Member
    Join Date
    Mar 2021
    Posts
    12
    Quote Originally Posted by kd5rxt-mark View Post
    @DeMoeP:

    Did you try connecting *only* the Teensy & the Audio Adapter together - with absolutely no other hardware ?? Running the WaveFilePlayer code with that simple setup would be a useful test. Any additional hardware (especially if it is sharing pins with those used by the Audio Adapter - I think that is what Frank B is referring to) only complicates the troubleshooting unnecessarily.

    Mark J Culross
    KD5RXT
    I did, first I unassigned all the unnecessary pins and then the teensy by itself and still no audio, something weird happened to it because from working perfectly to no audio at all in a matter of minutes makes me confused

  8. #8
    Senior Member
    Join Date
    Apr 2020
    Location
    DFW area in Texas
    Posts
    247

    Disconnect everything except the Teensy & the Audio Adapter - nothing else !!

    Quote Originally Posted by DeMoeP View Post
    I did, first I unassigned all the unnecessary pins and then the teensy by itself and still no audio, something weird happened to it because from working perfectly to no audio at all in a matter of minutes makes me confused
    Quote Originally Posted by DeMoeP View Post
    I did, first I unassigned all the unnecessary pins and then the teensy by itself and still no audio, something weird happened to it because from working perfectly to no audio at all in a matter of minutes makes me confused
    Again, did you *remove* all other *hardware* connections ?? Just "unassigning pins" is a *software* function & does not remove any potential *hardware* conflicts.

    Please understand that I'm not yelling, just wanting to clearly emphasize the points & distinguish between changing the software (assigning pins, unassigning pins, changing the mode of pins, etc.) & changing the hardware (removing ALL other connections . . . leaving ONLY the Teensy & the Audio Adapter . . . NOTHING else !!).

    Mark J Culross
    KD5RXT

Posting Permissions

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