Demo

This example plays notes on MIDI channel 1 with MIDI NoteOn and NoteOff to specify note values and velocity.

Plug a DIN-5 MIDI cable or 3.5mm TRS cable into the MIDI FeatherWing MIDI out port on one end and your favorite MIDI-capable synthesizer on the other.

In the example shown in the video above, a 3.5mm TRS MIDI cable is being used to have the Feather send notes to a KORG NTS-1 synthesizer module.

To use the MIDI FeatherWing with Arduino, first, get set up with Arduino IDE as detailed here.

Libraries

To add libraries, in the Arduino IDE click Sketch > Include Library > Manage Libraries...

In the Library Manager window, search for the MIDI Library by Francois Best, Iathoub and install the latest version.

Note: this is the same library that used to be known as the Forty Seven Effects MIDI library. Loads of great details to be had here!

Upload Code

Copy the code example below then paste it into a new Arduino document. Save the Arduino file, then compile and upload it to your Feather board. Once uploaded, it will begin sending MIDI to your synth!

// SPDX-FileCopyrightText: 2021 John Park for Adafruit Industries
// SPDX-License-Identifier: MIT

// MIDI FeatherWing note player example


#include <MIDI.h>

MIDI_CREATE_DEFAULT_INSTANCE();

int notes[] = {69, 72, 74, 76, 72, 81, 79};  // melody notes
int vels[] = {127, 96, 64, 96, 32, 127, 64};  // velocity per note
int rests[] = {50, 50, 50, 50, 50, 200, 50};  // rests between notes
int note_mods[] = {0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 5, 5, 3, 3};  // modifies notes for progression

void setup(){
    MIDI.begin(MIDI_CHANNEL_OMNI);
}

void loop() {

  for(int j=0; j<16; j++){  // loop through four measures for progression
    for(int i=0; i<7; i++){ //
      MIDI.sendNoteOn(notes[i]+note_mods[j], vels[i], 1);
      delay(100);
      MIDI.sendNoteOff(notes[i]+note_mods[j], 0, 1);
      delay(rests[i]);
    }
  }
}

This guide was first published on Mar 23, 2021. It was last updated on 2021-03-26 17:59:15 -0400.

This page (Arduino MIDI Example) was last updated on Apr 13, 2021.

Text editor powered by tinymce.