Midi - How to change program channel

Hello,

I am confused on how to change the channel of the program command in MIDI.

What I am trying to accomplish is to change the program (instrument) on channel 1, 2, 3… instead of the default 0.

Using noteOn analogy:

void noteOn(byte channel, byte note, byte attack_velocity) {  //Send a MIDI note-on message.  Like pressing a piano key
  talkMIDI( (0x90 | channel), note, attack_velocity);        //channel ranges from 0-15

I thought this would work for program change :

talkMIDI(0xC0|channel, instrument, 0);

But it is not changing the channel instrument ( changing channel to 1 or 2)

Anyone know how to change the channel using the change program command?

I thought this would work for program change :

Yes that is how to do it.
Except you must send it to the channel you want to change, so did you change the channel variable to 1 to send it to channel 2.
Also program change only requires two bytes so don’t add the ,0 as a third parameter.

I am not familiar with that library so don’t know if there is any other call.

Then send all your note on / off messages to this new channel.

Thanks Mike. It is working. Silly me was using noteOn on different channel.