midi problem

I’ve set up a bank of 4 footswitches to send specific midi program change messages and light LEDs to indicate what’s been pressed most recently. However, a curious issue has arisen.

The receiving device ignores the midi from the arduino, but if I connect a commercial midi pedal, send any signal to it, then reconnect the ardunio, it responds as it should. Is there a midi message I need to send to “wake up” the receiving device?

Here’s the code, apologies if it’s crude, I’ve never done this before and cobbled it together from various existing codes.

#include <MIDI.h>

// Constants
#define SWITCH1 2
#define SWITCH2 3
#define SWITCH3 4
#define SWITCH4 5
#define LED1 13
#define LED2 12
#define LED3 11
#define LED4 10
#define SWITCHES 4 // how many switches?
#define BOUNCEDELAY 100

// Variables:
int switches[SWITCHES] = { SWITCH1, SWITCH2, SWITCH3, SWITCH4 };
int switchState[SWITCHES] = { HIGH, HIGH, HIGH, HIGH }; // Initial state of switch is high due to internal pullup
int leds[SWITCHES] = { LED1, LED2, LED3, LED4 };
int currentSwitch = 0;
int thisLed = 0;
int activeLed = 0;
int currentProgram = 22; // current program - sent to the output

void setup()
{
MIDI.begin(1);
MIDI.sendProgramChange ( 8,1 ); // slap off
MIDI.sendProgramChange ( 5,1 ); // click off

MIDI.sendProgramChange ( currentProgram,1 );
// Setup Switches and activation LEDs
for( currentSwitch = 0; currentSwitch < SWITCHES; 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
}
}

void loop()
{

for( currentSwitch = 0; currentSwitch < SWITCHES; currentSwitch++ )
{
if ( (digitalRead(switches[currentSwitch]) != switchState[currentSwitch] ) && (switchState[currentSwitch] == HIGH) )
{
switch( currentSwitch )
{
case 0:
MIDI.sendProgramChange ( 1,1 ); // tap
lightPin(currentSwitch);
break;
case 1:
MIDI.sendProgramChange ( 16,1 ); // stop/start
lightPin(currentSwitch );
break;
case 2:
MIDI.sendProgramChange ( 2,1 ); // reset
lightPin(currentSwitch );
break;
case 3:
MIDI.sendProgramChange ( 21,1 ); // delay
lightPin(currentSwitch );
break;
}
delay( BOUNCEDELAY );
}
switchState[currentSwitch] = digitalRead( switches[currentSwitch] );
}
}

void lightPin( int activeLed ) // switch chosen LED on, others off
{
for( thisLed = 0; thisLed < SWITCHES; thisLed++ )
{
if (activeLed == thisLed)
{
if (activeLed == 0)
{
flashPin(leds[0]); // flash if it’s recording
}
else
{
digitalWrite( leds[thisLed], HIGH );
}
}
else
{
digitalWrite( leds[thisLed], LOW );
}
}
}

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