Need help to write a MIDI message.

I have this sequencer Yamaha QY10 I need to control from Arduino based MIDI controller to start and stop PLAY. I have to write code in Arduino program to get QY10 to play and stop. I need to know what type message it is. Is it Control Change or something else. From QY10 MIDI Data Format I get that
START=STATUS_____11111010____(FAH)
CONTINUE=STATUS____11111011___(FBH)
STOP=STATUS____11111100____(FCH)
Can anybody explain how to use this with Arduino programming.

It's Real Time message (look at : MIDI Specification)

You just have to send 0xFA to start, 0xFB to stop, 0xFC to continue through your serial port.

To do that, you need to set the speed of serial out to 31200 bauds.

There are some libraries to do that on the arduino : like Arduino Playground - MIDILibrary

Read these docs and you will success !

Grag38:
Read these docs and you will success !

Not so. After some hours reading reference again and again and trying.
If I write this

#include <MIDI.h>

byte Start = 0;

void setup() {

  Serial.begin(31250);
}
 
  
void loop() {
 

 MIDI.sendRealTime(Start)

  }
   }

I get error
'class MIDI_Class' has no member named 'sendRealTime'
I have no clue.

Does it look really so stupid that no answer is deserved?

Do any of the other MIDI class functions compile/link/work?

#include <MIDI.h>
byte Start = 0;
int valPin = 0;
int val;
int threshold = 600;

void setup() {

  Serial.begin(31250);   // set MIDI baud rate

 
  
}

void loop() {
  MIDI.sendProgramChange (12,1);
  val = analogRead(valPin);
  if (val <= threshold-100) { //-100 that slight change will not affect
 MIDI.sendNoteOn(66,127,1);
delay(300);
 

      }

  
  }

This compiles and works well.

void setup() {
  //  Set MIDI baud rate:
  Serial.begin(31250);
}

void loop() {
 
}

void Start(int realtime) {
  Serial.print(realtime, BYTE);
  
}

This one compiles as well, but does not produce MIDI message Start.

This one compiles as well, but does not produce MIDI message Start.

You never call the Start function.

void setup() {
 
  Serial.begin(31250);
}

void loop() {
  int Start = 1;
  int Stop = 1;
  Serial.print(Start, BYTE);
  delay(1000);
  Serial.print(Stop, BYTE);
  delay(1000);

  
}

This sends Song Select 1 in 1 sec interval but nothing else.

#include <MIDI.h>
byte Start = 0;

void setup() {
 
  Serial.begin(31250);
}

void loop() {
  MIDI.sendNoteOff(44,0,1);
  MIDI.sendControlChange(12,3,1);
  MIDI.sendSongPosition(2);
  MIDI.sendSongSelect(2);
  MIDI.sendRealTime(Start);
  
  
}

This is just a test what members are working. None after CC results this

sketch_oct20a.cpp: In function 'void loop()':
sketch_oct20a:11: error: 'class MIDI_Class' has no member named 'sendSongPosition'
sketch_oct20a:12: error: 'class MIDI_Class' has no member named 'sendSongSelect'
sketch_oct20a:12: error: 'SongNumber' was not declared in this scope
sketch_oct20a:13: error: 'class MIDI_Class' has no member named 'sendRealTime'

This sends Song Select 1 in 1 sec interval but nothing else.

  int Start = 1;
  int Stop = 1;
  Serial.print(Start, BYTE);
  delay(1000);
  Serial.print(Stop, BYTE);
  delay(1000);

Shouldn't Stop have a different value?

None after CC results this

Post YOUR MIDI.h file. You might have an older version.

Post YOUR MIDI.h file. You might have an older version.

Yes he does when I download from here:-
http://www.arduino.cc/playground/Main/MIDILibrary
This will compile

#include <MIDI.h>
kMIDIType startByte;

void setup() {
 
  Serial.begin(31250);
}

void loop() {
  MIDI.sendNoteOff(44,0,1);
  MIDI.sendControlChange(12,3,1);
  MIDI.sendSongPosition(2);
  MIDI.sendSongSelect(2);
  MIDI.sendRealTime(startByte);  
  
}

I don't understand. Where should I get(download) the MIDI.h file from. Because the MIDI library that comes with Arduiono0022 does not compile this. Downloading from the playground looks the same MIDI.h(created on 13.mai,2011). And this sample code

#include <MIDI.h>
kMIDIType startByte;

void setup() {
 
  Serial.begin(31250);
}

void loop() {
  MIDI.sendNoteOff(44,0,1);
  MIDI.sendControlChange(12,3,1);
  MIDI.sendSongPosition(2);
  MIDI.sendSongSelect(2);
  MIDI.sendRealTime(startByte);  
  
}

will not compile
error:
sketch_oct20a:1: error: 'kMIDIType' does not name a type
sketch_oct20a.cpp: In function 'void loop()':
sketch_oct20a:11: error: 'class MIDI_Class' has no member named 'sendSongPosition'
sketch_oct20a:12: error: 'class MIDI_Class' has no member named 'sendSongSelect'
sketch_oct20a:13: error: 'class MIDI_Class' has no member named 'sendRealTime'
sketch_oct20a:13: error: 'startByte' was not declared in this scope
I am utterly confused. All this is rather difficult to understand in anyway and I assume I am making stupid mistakes. But if there is a problem in somewhere else than my lack of understanding then I would never catch it, don't I. I appreciate you effect to guid me, but could you be more specific, please.

Because the MIDI library that comes with Arduiono0022 does not compile this.

The MIDI library does not come with the Arduino IDE. Some examples of using MIDI apparently do, but not the library.

Grumpy_Mike provided the link to the library. After downloading the library, it needs to be installed in the right place. Exactly where it goes depends on your operating system.

Where did you put it? Did you restart the IDE after installing the library?

Just to let you know I downloaded this today and put it in my libraries folder, restarted the arduino. Then I compiled it and after correcting a few errors you had it complied.
So I can't be more specific than that.

It looks like your installation is not quite right.

Thank you confirming and explaining. This lead me to check my installed libraries. The problem was that in my libraries I had several midi libraries - however with different folder names installed and two of them included MIDI.h. So Arduino IDE pulled not MIDI.h I needed.
So I got this sorted. Thanks!

So I try to make Arduino send Start>wait 1sec>send Stop>wait 1sec>....But I get nothing but ”reset” on MidiMonitor.

#include <MIDI.h>
kMIDIType startByte;
kMIDIType stopByte;

void setup() {
 
  Serial.begin(31250);
}

void loop() {
  
  MIDI.sendRealTime(startByte);
  delay(1000);
  MIDI.sendRealTime(stopByte);
  delay(1000);
  
}

You have not defined startByte and stopByte as anything. These are just empty variables, you must put a value after the definition. These are enum types so see the documentation for what values are available or look inside the library code where this data type is defined.

Thank you! To sum this up:

  1. get MIDI library v.3.1.1
  2. make sure you have only one MIDI.h in the Arduino library
  3. define kMIDIType
#include <MIDI.h>
kMIDIType startByte = Start;
kMIDIType stopByte = Stop;

void setup() {
 
  Serial.begin(31250);
}

void loop() {//send following continuously
  
  MIDI.sendRealTime(startByte);//send Start
  delay(3000);//wait 3sec
  MIDI.sendRealTime(stopByte);//send Stop
  delay(3000);//wait 3sec
  
}

I would have not been able to figure this out just by looking at the documentation without example. And I hope it will be helpful for somebody in the future. We have now an example.
So, great I can go on with my project now.

So after some trial/error and help of this http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1289056519
I came up with this

byte START = 0;
byte STOP = 0;


void setup()
{
Serial.begin(31250);
}

void loop()  {
  START = 0xFA;
   Serial.print(START, BYTE);
    delay(1000);
  STOP = 0xFC;
   Serial.print(STOP, BYTE);
     
      delay(1000);{
     
   } 
}

No need for MIDI library at all.

No need for MIDI library at all.

My feelings completely. There is an over emphasis about libraries, they give you a short term gain but ultimately mask what is going on.

void loop()  {
  START = 0xFA;
   Serial.print(START, BYTE);
    delay(1000);
  STOP = 0xFC;
   Serial.print(STOP, BYTE);

Doesn't the simpler:

const byte START = 0xfa;
const byte STOP = 0xfc;
void loop()  {
   Serial.print(START, BYTE);
    delay(1000);

   Serial.print(STOP, BYTE);

work?
I don't see what having START and STOP as variables gives you.

AWOL:
I don't see what having START and STOP as variables gives you.

Mostly the feeling that I do not understand completely what I am doing with coding.
Thanks for enlightenment.