Arduino Uno MIDI to BiasFX

Hi,

I threw together few components today in order to play with changing and bypassing effects, switching between different presets, etc.
I am using Uno -> hairless midi -> loopMIDI -> biasFx. Serial midi should work, because in Addictive drummer I can hear the inputs, and switch button action, but Bias doesn't recognize thoose inputs.
Code is slightly modified (remaped inputs and outputs) version of this tutorial MidiFoot. I looked up for some midi codes, but nothing seems to work for me, atleast not in bias. Is it Arduino sending commands problem, is it problem with PC software, or there is some third problem?

My code is as follows

// midi.controller
// written by The Cat Herder
// Sends midi program change and control change messages based on foot pedal pressed

// Constants
#define SWITCH1 7
#define SWITCH2 8
#define SWITCH3 12
#define SWITCH4 9
#define SWITCH5 6 
#define LED1 3
#define LED2 4
#define LED3 5
#define LED4 6
#define LED5 2
#define BOUNCEDELAY 25

// Variables: 
int switches[5] = { SWITCH1, SWITCH2, SWITCH3, SWITCH4, SWITCH5 };
int switchState[5] = { HIGH, HIGH, HIGH, HIGH, HIGH }; 
// Initial state of switch is high due to internal pullup
int leds[5] = { LED1, LED2, LED3, LED4, LED5 };
int currentSwitch = 0;
int currentProgram = 22;   // current program - sent to the output
int bypassState = LOW;     // state of bypass pedal
int pedalActiveFlash = 50; // Delay for flash when pedal is pressed

void setup() {
  //  Set MIDI baud rate:
  Serial.begin(31250);

  // Setup Switches and activation LEDs
  for( currentSwitch = 0; currentSwitch < 5; currentSwitch++ ) {
    pinMode( switches[currentSwitch], INPUT );          // Set pin for switch
    digitalWrite( switches[currentSwitch], HIGH );      // Turn on internal pullup
    pinMode( leds[currentSwitch], OUTPUT );             // Set pin for LED
    flashPin( leds[currentSwitch], 100 ); // Flash LED
  }
}

void loop() {
  for( currentSwitch = 0; currentSwitch < 5; currentSwitch++ ) {
    if((digitalRead(switches[currentSwitch]) != switchState[currentSwitch] )&&(switchState[currentSwitch] == HIGH)){
      switch( currentSwitch ) {
        case 0:
          //Bypass
          if( bypassState == LOW ) {
            bypassState = HIGH;
            midiSend( 0xB0, 0x5B, 0x00 ); // bypass off
            digitalWrite( leds[currentSwitch], LOW );
          }
          else {
            bypassState = LOW;
            midiSend( 0xB0, 0x5B, 0x7F ); // bypass on
            digitalWrite( leds[currentSwitch], HIGH );
          }
          break;
        case 1:
          //Prev Program
          currentProgram = currentProgram--;
          if( currentProgram < 1 )
            currentProgram = 0; // Don't go lower than 0
          midiProg( 0xC0, currentProgram );
          flashPin( leds[currentSwitch], pedalActiveFlash );
          break;
        case 2:
          // Next Program
          currentProgram = currentProgram++;
          if( currentProgram > 96 )
            currentProgram = 97; // Don't go lower than 97
          midiProg( 0xC0, currentProgram );
          flashPin( leds[currentSwitch], pedalActiveFlash );
          break;
        case 3:
          // Favourite 1
          currentProgram = 22;
          midiProg( 0xC0, currentProgram );
          flashPin( leds[currentSwitch], pedalActiveFlash );
          break;
        case 4:
          // Favourite 2
          currentProgram = 27;
          midiProg( 0xC0, currentProgram );
          flashPin( leds[currentSwitch], pedalActiveFlash );
          break;
      }
      delay( BOUNCEDELAY );
    }
    switchState[currentSwitch] = digitalRead( switches[currentSwitch] );
  }  
}

//  Send a three byte midi message  
void midiSend(char status, char data1, char data2) {
  Serial.write(status);
  Serial.write(data1);
  Serial.write(data2);
}

//  Send a two byte midi message  
void midiProg(char status, int data ) {
  Serial.write(status);
  Serial.write(data);
}

void flashPin( int ledPin, int flashDelay ) {
  digitalWrite( ledPin, HIGH );
  delay( flashDelay );
  digitalWrite( ledPin, LOW );
}

Is there any definitive guide to what this amp software on pc requires, list of commands, notes, etc. Or is it just send me anything and I will assign it to something.

Thank you very much for any help, I appreciate it a lot.
Have a nice day/evening

Denis

Okay, for reasons unknown to me BiasFX wanted to have connected my USB soundcard when using ASIO input, other programs don't have such problem. Basic template using three buttons and three leds to control BiasFX is bellow.

Setup is, Arduino UNO (over usb cable) => Hairless MIDI => loopMIDI, then you use correct interface created in loopMIDI as MIDI input in BiasFX. Channels and midi library funcitons are well documented here Midi library docs.
I'll make pedal board with few switches and SSD1306 OLED screen, will post the code when I will finish it. For now below is working example of program change and control. Program change is used for swaping between different presets, and control is for turning switches on and off.

Have a nice day

EDIT: I aslo changed baudrate in MIDI library in file midi_Settings.h -line with

static const long BaudRate = 115200;
#include <MIDI.h>
#include <Bounce2.h>

// Push button start and end pins (only works in sequence)
int button1 = 7;  
int button2 = 8;  
int button3 = 9;

int bounceDelay = 5;

// Push buttons
Bounce Button1 = Bounce();  
Bounce Button2 = Bounce();  
Bounce Button3 = Bounce();

// Button state
int button1State;  
int lastButton1State;  
int button2State;  
int lastButton2State;  
int button3State;  
int lastButton3State;

// LED pins
int led1 = 3;  
int led2 = 4;  
int led3 = 5;

MIDI_CREATE_DEFAULT_INSTANCE(); // Create an instance of MIDI

void setup() {  
  MIDI.begin();
  //Serial.begin(115200);

  pinMode(button1,INPUT);
  pinMode(button2,INPUT);
  pinMode(button3,INPUT);

  pinMode(led1,OUTPUT);
  pinMode(led2,OUTPUT);
  pinMode(led3,OUTPUT);

  Button1.attach(button1);
  Button1.interval(bounceDelay);
  Button2.attach(button2);
  Button2.interval(bounceDelay);
  Button3.attach(button3);
  Button3.interval(bounceDelay);
}
void loop() {  
  Button1.update();
  Button2.update();
  Button3.update();

  button1State = Button1.read();
  button2State = Button2.read();
  button3State = Button3.read();

  delay(5);

  if (button1State != lastButton1State) {
    if (button1State == LOW) { 
      digitalWrite(led1, HIGH); 
      MIDI.sendControlChange(16,127,1); //Send cotnroll change (CC#, value, channel)
      delay(100);
      digitalWrite(led1, LOW);
    } 
    lastButton1State = button1State;
  }

  if (button2State != lastButton2State) {
    if (button2State == LOW) {  
      digitalWrite(led2, HIGH);
      MIDI.sendControlChange(82,127,1);  // Send cotnroll change (CC#, value, channel)
      delay(100);
      digitalWrite(led2, LOW);
    } 
    lastButton2State = button2State;
  }

  if (button3State != lastButton3State) {
    if (button3State == LOW) {  
      digitalWrite(led3, HIGH);
      MIDI.sendProgramChange(6, 1);  // Send program change (PC#, channel)
      delay(100);
      digitalWrite(led3, LOW);
    } 
    lastButton3State = button3State;
  }
}