EASY Midi Controler Bank Changing

Hi guys, as many of you I’m trying the arduino and have a problem that i can’t solved.

My code seems to work except the MIDI things (My soundcard receive any of arduino MIDI message).

The object : a 4 momentary switches with 4 LED.
A switch pressed active the LED and send a Midi Bank Change message.

My problem is that the MIDI message seems wrong, it doesn’t seems to be understandable by my sequencer Reaper (it works well with my Highly Liquid Midi controler)

I’m sure that it’s not complicated, I may have missed something ?
Thank you guys :slight_smile:

#include <MIDI.h>

 //https://forum.arduino.cc/index.php?topic=317194.0
MIDI_CREATE_DEFAULT_INSTANCE();
 
void setup() {

  //start serial connection
  Serial.begin(31250); 

  pinMode(2, INPUT);
  pinMode(3, INPUT);
  pinMode(4, INPUT);
  pinMode(5, INPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
}
void loop() {

  //read the pushbutton value into a variable
  int sensorVal1 = digitalRead(2);
  int sensorVal2 = digitalRead(3);
  int sensorVal3 = digitalRead(4);
  int sensorVal4 = digitalRead(5);
      
  if (sensorVal1 == HIGH) {
    delay(50);
    digitalWrite(9, HIGH);   
    digitalWrite(10, LOW);
    digitalWrite(11, LOW); 
    digitalWrite(12, LOW);
    MIDI.send(midi::ProgramChange, 0, 0, 1); 
    delay(100);        
  } 
  else if (sensorVal2 == HIGH) {
    delay(50);
    digitalWrite(9, LOW);   
    digitalWrite(10, HIGH);
    digitalWrite(11, LOW); 
    digitalWrite(12, LOW);
    MIDI.send(midi::ProgramChange, 1, 0, 1); 
    delay(100); 
  }
  else if (sensorVal3 == HIGH) {
    delay(50);
    digitalWrite(9, LOW);   
    digitalWrite(10, LOW);
    digitalWrite(11, HIGH); 
    digitalWrite(12, LOW);
    MIDI.send(midi::ProgramChange, 2, 0, 1);
    delay(100); 
  }
  else if (sensorVal4 == HIGH) {
    delay(50);
    digitalWrite(9, LOW);   
    digitalWrite(10, LOW);
    digitalWrite(11, LOW); 
    digitalWrite(12, HIGH);
    MIDI.send(midi::ProgramChange, 3, 0, 1);
    delay(100); 
  }
}

Are you sure that code is what you have. It will not compile on my machine.

According to the MIDI.h file the program change code should be in the form of:-

sendProgramChange(DataByte inProgramNumber, Channel inChannel);

OK the problem was much easy...I find a wrong google image to connect my MIDI pin and the wiring is false.

Use this schematic : https://www.arduino.cc/en/Tutorial/Midi

About the "sendProgramChange" I will try and see what is sent :).

Ok one thing:

If I send MIDI.send(midi::ProgramChange, 0, 0, 1);

The Marshall amp recognize the signal only one time. I can switch 50000 times after, no signal MIDI is detected by the amp (but ok in my soundcard)

If I disable the signal just after sending the MIDI note it works :

Example :

MIDI.send(midi::ProgramChange, 0, 1, 1); // MIDI Channel 1 MIDI.send(midi::ProgramChange, 0, 1, 0); // MIDI Channel 0 = off

Isn't it weird ?

Did you try what Mike suggestedsendProgramChange(DataByte inProgramNumber, Channel inChannel);.

sendProgramChange(0, 1) for on. sendProgramChange(0, 0) for off.