Hi! I'm using a teensy 4.0 on a breadboard and trying to get 5 PIN MIDI in to work. I'm using the code and following the schematic from PJRC's Teensyduino library / MIDI located here
Here is the schematic (I'm only using the MIDI in side, not the MIDI out):
Here is the code:
Here is my actual circuit:
The code uploads fine and shows "MIDI Input test" on the serial moniter and then (inactivity) every 10 seconds and nothing else.
I have tested each wire with a multimeter and they all work. The Teensy works and I've gotten it to send 5 pin midi out previously. I tested the two resistors and they are the correct Ohms. I tested the diode and it's good.
The chip is a 6N138 and it came in a pack of 10. I have swapped out 3 of them and get the same result. They seem to be good though because when I took the wire going to Teensy pin 0 (Rx) and attached it to Pin 7 of the 6N138 and then ungrounded and regrounded the 6N138 (I did this by accident), the Teensy program read:
Message, type= 255, data = 0 0
Actually, I don't know if that means the chip is working or not. I note that this was an accident and the wire in question should go from Rx (pin 0 of the teensy) to pin 6 of the 6N138. I had attached it accidentally to 7 instead, which is when I got this weird result. This is the only time that the serial monitor has shown any MIDI activity.
I read on the PJRC MIDI library I linked to above that some 6N138s need pin 7 grounded through a 10k resistor and I tried that too. Also nothing.
I am using a keyboard (garageband keytar) attached by 5 pin midi that I tested elsewhere and worked (I also tried with an alternative keyboard, a Keystep, as well just in case, same result)
An additional piece of information is that the keyboard is designed to blink when it is on but not plugged into MIDI and then stop blinking when it is connected to MIDI. In this case, when I plug the keyboard MIDI into my circuit, the keyboard stops blinking, meaning the keyboard "thinks" it is attached to MIDI. Again though, NOTHING comes through on the serial monitor side except (inactivity) with the exception of the weird fluke I described above.
I have been staring at this thing / thinking about this for hours. I've checked and rechecked the connection of every component and I just cannot figure out what I'm missing. Any ideas would be GREAT. I'm at the point of thinking of abandoning 5 pin MIDI in and instead going for a Teensy 4.1 with USB host, which I've gotten working before. However, I would strongly prefer 5 pin midi in and host USB for this project.
Thank you so much in advance!
Here is the schematic (I'm only using the MIDI in side, not the MIDI out):
Here is the code:
Code:
/* MIDI Input Test - for use with Teensy or boards where Serial is separate from MIDI
* As MIDI messages arrive, they are printed to the Arduino Serial Monitor.
*
* Where MIDI is on "Serial", eg Arduino Duemilanove or Arduino Uno, this does not work!
*
* This example code is released into the public domain.
*/
#include <MIDI.h>
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);
void setup() {
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)");
}
}
Here is my actual circuit:
The code uploads fine and shows "MIDI Input test" on the serial moniter and then (inactivity) every 10 seconds and nothing else.
I have tested each wire with a multimeter and they all work. The Teensy works and I've gotten it to send 5 pin midi out previously. I tested the two resistors and they are the correct Ohms. I tested the diode and it's good.
The chip is a 6N138 and it came in a pack of 10. I have swapped out 3 of them and get the same result. They seem to be good though because when I took the wire going to Teensy pin 0 (Rx) and attached it to Pin 7 of the 6N138 and then ungrounded and regrounded the 6N138 (I did this by accident), the Teensy program read:
Message, type= 255, data = 0 0
Actually, I don't know if that means the chip is working or not. I note that this was an accident and the wire in question should go from Rx (pin 0 of the teensy) to pin 6 of the 6N138. I had attached it accidentally to 7 instead, which is when I got this weird result. This is the only time that the serial monitor has shown any MIDI activity.
I read on the PJRC MIDI library I linked to above that some 6N138s need pin 7 grounded through a 10k resistor and I tried that too. Also nothing.
I am using a keyboard (garageband keytar) attached by 5 pin midi that I tested elsewhere and worked (I also tried with an alternative keyboard, a Keystep, as well just in case, same result)
An additional piece of information is that the keyboard is designed to blink when it is on but not plugged into MIDI and then stop blinking when it is connected to MIDI. In this case, when I plug the keyboard MIDI into my circuit, the keyboard stops blinking, meaning the keyboard "thinks" it is attached to MIDI. Again though, NOTHING comes through on the serial monitor side except (inactivity) with the exception of the weird fluke I described above.
I have been staring at this thing / thinking about this for hours. I've checked and rechecked the connection of every component and I just cannot figure out what I'm missing. Any ideas would be GREAT. I'm at the point of thinking of abandoning 5 pin MIDI in and instead going for a Teensy 4.1 with USB host, which I've gotten working before. However, I would strongly prefer 5 pin midi in and host USB for this project.
Thank you so much in advance!