Skip to content

Step 1: create your sketch

Alex Simon edited this page Feb 20, 2015 · 5 revisions

MIDI library

In order for the sketch to work, we some extra functionality: the MIDI library.

  1. Download MIDILibrary 4.2 here
  2. Unzip
  3. Move the folder into your Documents/Arduino/libraries folder.

When you boot Arduino IDE the next time you should see the following: Arduino IDE

Sketch

#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();

#define CHANNEL 1

void setup() {
  // Initiate MIDI communications, listen to all channels
  MIDI.begin(MIDI_CHANNEL_OMNI);
}

void sendNote(byte note, byte velo, byte channel) {
  MIDI.sendNoteOn(note, velo, channel);  // Send a Note
  delay(1000);                           // Wait
  MIDI.sendNoteOff(note, 0, channel);    // Stop the note
}

void loop() {
  sendNote(24, 127, CHANNEL);
  delay(2000);
}

NEXT STEP

Clone this wiki locally