Sending MIDI Messages not working.

Hello,
Im trying to create a midi foot switch to control my AXE FX II unit (http://wiki.fractalaudio.com/index.php?title=MIDI is the MIDI CC messages). This is the schematic I’m using is attached.
This is the code:

#include <MIDI.h>
#include <midi_Defs.h>
#include <midi_Namespace.h>
#include <midi_Settings.h>
#include <Button.h>

int ledPin = 13;                //choose the pin for the LED - needs to be (3,5,6,9,10, or 11)
int buttonPin = 2;               //choose the input pin for a pushbutton
int buttonVal = 0;                    //variable for reading the button status
int buttonState = 0;            //variable to hold the buttons current state
int bounceCheck = 0;            //variable for debouncing

void setup() {
  pinMode(ledPin, OUTPUT);      //declare LED as output
  pinMode(buttonPin, INPUT);     //declare pushbutton as input
  Serial.begin(31250);            //MIDI communicates at 31250 baud
}

void loop(){

  buttonVal = digitalRead(buttonPin);     //read input value from button
  delay(10);                              //wait 10ms
  bounceCheck = digitalRead(buttonPin);   //check again
  if(buttonVal == bounceCheck){           //if val is the same then not a bounce
    if (buttonVal == HIGH && buttonState == 1) {   //check if the input is HIGH
      digitalWrite(ledPin, LOW);         //turn LED OFF
      MIDI.sendNoteOff(60,0,1);
      buttonState = 0;
    }
    if(buttonVal == LOW && buttonState == 0){
      digitalWrite(ledPin, HIGH);       //turn LED ON
      MIDI.sendNoteOn(60,127,1);
      buttonState = 1;
    }

  }

}

void midiOUT(char command, char value1, char value2) {
  Serial.write(command);
  Serial.write(value1);
  Serial.write(value2);

}
}

I’ve tried changing the numbers on the “MIDI.sendNoteOn(60,127,1);” and still nothing is changing. Can someone guide me which command should be sent to at least do one function?

MH_board_v4.png

Image is too big, please resize it. Are you able to send any midi message? You don't need the midiOUT function since you're using the midi library Go slowly, get rid of the button part and just send a midi note with a delay of 500 or so. How are you monitoring the output? The best would be to use a computer with any midi monitor, like midi-ox. Maybe your connection is wrong, sometimes it's hard to tell which pin is 4 and 5 on the midi connector.

Which command from the MIDI library would be suitable for the MIDI CC wiki page I posted? I connected directly to my AXE FX unit, and I keep uploading with different numbers to see if anything happens.

MIDI.sendControlChange(control number, value, channel); then you just have to check to what CC messages your unit responds, they're listed in the wiki

Thank you very much for the support, I’m nearly there. Using hairless midi, I found out that my old code used to send notes, thats why probably it wasnt working. But when I replaced the sender with the MIDI library function, for some reason nothing is being sent on the serial or captured by the hairless midi…

#include <MIDI.h>
#include <midi_Defs.h>
#include <midi_Namespace.h>
#include <midi_Settings.h>
#include </Users/nassar/Desktop/Test/midicontroller/Button.h>

int ledPin = 13;                //choose the pin for the LED - needs to be (3,5,6,9,10, or 11)
int buttonPin = 2;               //choose the input pin for a pushbutton
int buttonVal = 0;                    //variable for reading the button status
int buttonState = 0;            //variable to hold the buttons current state
int bounceCheck = 0;            //variable for debouncing

void setup() {
   MIDI.begin(0);

  pinMode(ledPin, OUTPUT);      //declare LED as output
  pinMode(buttonPin, INPUT);     //declare pushbutton as input
  Serial.begin(31250);            //MIDI communicates at 31250 baud
}

void loop(){

  buttonVal = digitalRead(buttonPin);     //read input value from button
  delay(10);                              //wait 10ms
  bounceCheck = digitalRead(buttonPin);   //check again
  if(buttonVal == bounceCheck){           //if val is the same then not a bounce
    if (buttonVal == HIGH && buttonState == 1) {   //check if the input is HIGH
      digitalWrite(ledPin, LOW);         //turn LED OFF
      MIDI.sendControlChange(1, 120, 1);
      buttonState = 0;
    }
    if(buttonVal == LOW && buttonState == 0){
      digitalWrite(ledPin, HIGH);       //turn LED ON
      MIDI.sendControlChange(1, 10, 1);

      buttonState = 1;
    }

  }

}

i would try monitoring with a computer btw if you use MIDI.begin() you don't have to use Serial.begin

Ya, that is what I am doing, for some reason nothing is being read on my mac using the MIDI library, my old code used to output notes.

Which one is your old working code? The first one? By the way, MIDI.begin(0) is wrong, it should be 1-16, or nothing. It shouldn't affect your code though.

Yes, the first one while monitoring I used to read the messages, now after MIDI.sendControlChange, there is no messages...

In your old code you're also using the MIDI library btw... try adding the noteon messages on your new code, along the CC ones

Why do you use the MIDI library? You waste lots of flash space on something simple as serial handling.

Sending MIDI is just a matter of writing it to the USART Tx reg if its not busy.