Go Down

Topic: Unable to send Program Change (Read 129 times) previous topic - next topic

jnrkirk

I am attempting to make a MIDI Footcontroller that sends a Midi Note and possibly a Program Change with the push of a button.  Right now I am just trying to get a Program change to transmit and it is sending a midi note.  I feel like Ive done a lot of research and tried several things but nothing will work.

Do you see any issues in my Code?  I do not have any comments as I am just in prototype mode. LOL

//MIDI.begin

#include <MIDI.h>
#include <midi_Settings.h>
#define txPin 1
const int channel = 1; 
MIDI_CREATE_DEFAULT_INSTANCE();

void setup() {
  // put your setup code here, to run once:
  Serial.begin(31250);
  pinMode(txPin, OUTPUT);
  pinMode(2, INPUT_PULLUP);
}

void loop() {
  // put your main code here, to run repeatedly:
  int button2 = digitalRead(2);

    if (button2 == LOW) {
    MIDI.sendControlChange(60, 127, 1);
    }
   
}

el_supremo

sendControlChange does not send a Program Change. Which do you want?
If you want Program Change the function has two arguments:
sendProgramChange(byte ProgramNumber,byte Channel)

Pete

jnrkirk

I have tried it with ProgramChange also and used only two arguments with that. 

When you say:
"sendProgramChange(byte ProgramNumber,byte Channel)" Does the "byte" have to be in the code? Sorry for the newbie questions. 

This morning I tried this exact code:

sendProgramChange(60, 1)   

When I open up ableton and press the button, It sends a C3 note on channel 1, Which would be note 60.  Not sure why its not recognizing the sendProgramChange.  I am using the MIDI library 4.2.


el_supremo

'byte' just tells you what type of argument the function expects and should not be included in your code when you call the function.
You also have a problem that while the button is LOW, you keep sending the Program Change code as fast as possible. This might confuse whatever is at the other end.
Try this for now:
Code: [Select]

    if (button2 == LOW) {
      MIDI.sendProgramChange(60, 1);
      delay(500);
    }

This will give you time to release the button.

Pete

jnrkirk

I figured out where I messed up.  I didn't use the MIDI.begin(1).  When I added this, everything works great now.  Thanks for the help.  Hope this might help someone else. 

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy