rveitch
9/12/2015 - 9:37 PM

Midi Program Change Example

Midi Program Change Example

/* Send a Program Change message
   \param inProgramNumber The Program to select (0 to 127).
   \param inChannel       The channel on which the message will be sent (1 to 16).
 */
// The first number is the program change number, and the second is the channel
// Example: MIDI.sendProgramChange (2, 12); // sends PC 2 on channel 12

// ------------------------------------Example--------------------------------------

void setup()
{
    pinMode(LED, OUTPUT);
    MIDI.begin();           // Launch MIDI, by default listening to channel 1.
}

void loop()
{
    if (MIDI.read())                // Is there a MIDI message incoming ?
    {
        switch(MIDI.getType())      // Get the type of the message we caught
        {
            case midi::ProgramChange:       // If it is a Program Change,
                BlinkLed(MIDI.getData1());  // blink the LED a number of times
                                            // correponding to the program number
                                            // (0 to 127, it can last a while..)
                break;
            // See the online reference for other message types
            default:
                break;
        }
    }
}