this code now works beautifully (in MIDIOX thus far, haven't tested with the hardware yet). It reads for a couple notes, and sends program change msgs up or down; sweet.
#include <MIDI.h>
/* set NRPN to set volume to zero for part xyz
read existing program/patch number ???
send stop control
*/
byte P = 1;
void HandleNoteOn (byte channel, byte note, byte velocity){
//if note1 or note2 is sent, send program change control to go up or down
if (note == 60){ //need to get the actual note number that I'll assign */
if (P == 127){P=1;
MIDI.sendProgramChange(P,10);
}
else
{
P++;
MIDI.sendProgramChange(P,10);
}
}
if (note == 62){ //need to get the actual note number that I'll assign
if (P== 1){ P=127;
MIDI.sendProgramChange(P,10);
}
else { P--;
MIDI.sendProgramChange(P,10);
}
}
}
//if note3 is sent, send nrpn to set volume to zero
void setup() {
MIDI.begin(MIDI_CHANNEL_OMNI);
MIDI.turnThruOff();
MIDI.setHandleNoteOn(HandleNoteOn);
MIDI.sendProgramChange(P,10);
}
void loop () {
MIDI.read(); //is there incoming MIDI?
}