Hello, I used this schematic from the Notes and Volts video to build a MIDI hardware serial port for my Yamaha P95, but after I uploaded this code:
#include <MIDI.h>
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);
// -----------------------------------------------------------------------------
// This example shows the old way of checking for input messages.
// It's simpler to use the callbacks now, check out the dedicated example.
const int Led14 = 14;
// -----------------------------------------------------------------------------
void BlinkLed(byte num) // Basic blink function
{
for (byte i=0;i<num;i++)
{
analogWrite(Led14, 5);
delay(50);
analogWrite(Led14, 0);
delay(50);
}
}
// -----------------------------------------------------------------------------
void setup()
{
pinMode(Led14, OUTPUT);
MIDI.begin(); // Launch MIDI, by default listening to channel 1.
}
void loop()
{
if (MIDI.read()) // Is there a MIDI message incoming ?
{
switch(MIDI.getType()) // Get the type of the message we caught
{
case midi::ProgramChange: // If it is a Program Change,
BlinkLed(MIDI.getData1()); // blink the LED a number of times
// correponding to the program number
// (0 to 127, it can last a while..)
break;
// See the online reference for other message types
default:
break;
}
}
}
the Teensy behave like this:
I have zero knowledge about Arduino, programming language and the Teensy.
The only thing I know now, is how to add a led to the circuit and use it in place of the one embedded in the Teensy.
The components I used in the circuit:
- 5 Pin DIN female plug
- 220 Ohm resistor
- 470 Ohm resistor
- 6N138 optocoupler
- 1N4148 diode
- Teensy Audio Shield Rev D (I had to solder the pins for the breadboard and sandwich connection with the Teensy 4.0)
Pin 2 and 3 are connected with the 1N4148 diode, there is a 220 Ohm resistor bridge with the jumper that connects to the Pin 5 of the MIDI connector.
Pin 5 of the MIDI connector is connected to Pin 3 of the optocoupler (there is a bridge with the 1N4148 diode).
Pin 8 is connected to the 5V of the Teensy.
Pin 6 of the optocupler is connected to the RX1 (Pin 0) of the Teensy. After the jumper wire, you can see the 470 Ohm resistor connected to the 3.3V of the Teensy.
Pin 5 of the optocoupler is connected to GND.
I upload the sketch, plug the MIDI cable, turning on the keyboard and the led goes berserk.
Does the code indicates that there is communication between the keyboard and the Teensy and that is working properly?
I don't understand what this supposes to mean and what I am doing wrong.






