|
Post by mjb on Nov 28, 2016 13:44:46 GMT
Here is a simple MIDI sketch. It works with this MIDI shield that uses the Tx pin (D1):
www.ebay.co.uk/itm/152294506755?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT
You will need to download the latest ShieldBuddy software to get the MIDI's 31250 bit/s! Overwrite the Core 0 setup() and loop() but do not touch the Core 1 and Core2 equivalents otherwise it will not compile.
/*** Core 0 ***/
void setup() { // put your setup code for core 0 here, to run once: Serial.begin(31250); // Midi Baudrate
}
void noteOn(int cmd, int pitch, int velocity);
void loop() { // play notes from F#-0 (0x1E) to F#-5 (0x5A): for (int note = 0x1E; note < 0x5A; note ++) { //Note on channel 1 (0x90), some note value (note), middle velocity (0x45): noteOn(0x90, note, 0x45); delay(100); //Note on channel 1 (0x90), some note value (note), silent velocity (0x00): noteOn(0x90, note, 0x00); delay(100); }
}
void noteOn(int cmd, int pitch, int velocity) { Serial.write(cmd); Serial.write(pitch); Serial.write(velocity); }
|
|