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

Thread: Hardware serial receive not working - pin 28 on teensy 4.1

  1. #1

    Hardware serial receive not working - pin 28 on teensy 4.1

    I'm trying to use pin 28 as hardware serial7 for 5 pin midi in. I tested the 5 pin midi in and it worked on pin 0 with serial1 using the example midi in program. The only change I have made from that program is to add Serial1.setRX(28), which should allow serial1 to use pin 28. But it's not working at all. My MIDI notes are not being received. The reason I'm using pin 28 is because I am using teensy 4.1 with the audio shield, so pints 1-23 are all hooked up to the audio shield. Thank you!

    Code:
    #include <MIDI.h>
    
    
    MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);
    
    
    void setup() {
     Serial1.setRX(28);
      MIDI.begin(MIDI_CHANNEL_OMNI);
      Serial.begin(57600);
      Serial.println("MIDI Input Test");
    }
    
    unsigned long t=0;
    
    void loop() {
      int type, note, velocity, channel, d1, d2;
      if (MIDI.read()) {                    // Is there a MIDI message incoming ?
        byte type = MIDI.getType();
        switch (type) {
          case midi::NoteOn:
            note = MIDI.getData1();
            velocity = MIDI.getData2();
            channel = MIDI.getChannel();
            if (velocity > 0) {
              Serial.println(String("Note On:  ch=") + channel + ", note=" + note + ", velocity=" + velocity);
            } else {
              Serial.println(String("Note Off: ch=") + channel + ", note=" + note);
            }
            break;
          case midi::NoteOff:
            note = MIDI.getData1();
            velocity = MIDI.getData2();
            channel = MIDI.getChannel();
            Serial.println(String("Note Off: ch=") + channel + ", note=" + note + ", velocity=" + velocity);
            break;
          default:
            d1 = MIDI.getData1();
            d2 = MIDI.getData2();
           // Serial.println(String("Message, type=") + type + ", data = " + d1 + " " + d2);
        }
        t = millis();
      }
      if (millis() - t > 10000) {
        t += 10000;
        Serial.println("(inactivity)");
      }
    }

  2. #2
    The solution was just to use Serial7 instead of SetRX.

    That and also it turns out I hadn't connected up power. Sorry.

    This is RESOLVED.

Posting Permissions

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