Hello, I want to make midi controller and I need midi through to connect keyboard. Now only Midi In and Midi Out connected to Arduino. Midi OX shows double note on and note off when I press keyboard. As it is pretty simple code and setup, I am stuck at troubleshooting. Maybe anyone had this problem, and solved?
Code
#include <MIDI.h>
#define LED 13
void NoteOnAction(byte channel, byte pitch, byte velocity) {
digitalWrite(LED,HIGH);
if (velocity == 0){
digitalWrite(LED,LOW);
}
}
void setup() {
pinMode (LED, OUTPUT);
MIDI.begin(MIDI_CHANNEL_OMNI);
MIDI.setHandleNoteOn(NoteOnAction);
}
void loop() {
MIDI.read();
}
Midi in schematic (I did not connect 6 pin (where 100K goes to ground), as it wasn`t working that way).

Also, I do not quite understand Midi.library logic. I thought that I always need to use callbacks. Example: If I want midi through: I listen to noteOn message, and send callback function with noteOn pitch and velocity. But it seems that library do it, without any callback code.

OMG that was so stupid, there was just two listener devices in Midi OX. Sorry for this post.
If it possible to make delay for only one function in a loop? What I am trying to achieve, to send CC with delay (as many midi data crashes my synth) but sending note on, not off messages without delay. Is it possible to make something like two loop functions?
With this code notes stuck on delay at CC function. How to make note avoid delay, but keep delay for sending CC?
void loop() {
val = map(analogRead(1), 0, 1023, 127, 0);
if (oldVal != val){
MIDI.sendControlChange (22, 24, 1);
MIDI.sendControlChange (23, val, 1);
oldVal = val;
delay(100);
}
MIDI.read();
}
UPD.: ok, I figured out that I can just make for timer to CC function and exclude delay from loop. UPD2: that not working, as for cycle goes too fast.
Also my keyboard sends Midi realtime messages through Arduino. Is there a way to filter it out?
Is it possible to make something like two loop functions?
You can only have one loop function.
You can however delay the passing on of a note or CC message by using the millis timer and the technique in the blink without delay example. But in place of blinking you want to send your CC message.