Oh! Arduino day! Now I got rid of the "void" and put everything in the loop leaving Serial.begin there as well.
I increased the baud rate up to 115200 and changed the stop note to the same as record but with the different velocity (it's more like DAW style).
As a result more consistency but still couple times during the testing the system refused to respond.
Any ideas?
Now it looks like this:
byte incomingByte;
byte noteByte;
byte velocityByte;
byte noteOn=0x90;
void setup(){
Serial.begin(115200);
pinMode(12,OUTPUT);
}
void loop()
{
delay(2);
Serial.begin(115200);
{
if(Serial.available () > 2){
incomingByte = Serial.read();
noteByte = Serial.read();
velocityByte = Serial.read();
if (incomingByte == noteOn & noteByte == 95 & velocityByte > 0){
digitalWrite(12,HIGH);
}
else
if (incomingByte == noteOn & noteByte == 95 & velocityByte ==0){
digitalWrite(12,LOW);
}
}
}
}