i am trying to build a midi controller with my arduino to control software. i use Serial_MIDI to convert the serial messages to midi.
The problem is i don't know what the format is of the midi messages so that the converter can read it.
This is my code. when i press button 51 it should light up the led and send a midi message.
// set pin numbers:
int buttonPin = 51; // the number of the pushbutton pin
int ledPin = 53; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
Serial.begin(115200);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
Serial.print("????????"); <----------------------------- what do i need to insert here?
//MIDImessage()
// prints hello with ending line break
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
sorry if it is a stupid question. i'm just totally unfamilliar with midi and i just want my arduino to send a single message to the converter so i can let my software react to the push of a button.
Serial_MIDI says the midi message contains of 3 bytes and the first byte is seperated in an action part and a command part.
so i first tried sending 3 bytes
Serial.write(B00000100);
Serial.write(B00000100);
Serial.write(B00000100);
(the prefix B should also work right? Integer Constants - Arduino Reference)
and i tried splitting the action part and command part
Serial.write(B0010);
Serial.write(B0010);
Serial.write(B00000100);
Serial.write(B00000100);
but in the conversion software the light still turns red (which means it is reading serial data but it's not midi format.