Skip to main content

Using Wio Terminal as a USB MIDI Device

This repo introduce how to use the Wio Terminal as a USB MIDI (Musical Instrument Digital Interface) Device, where it can be used to control musical instruments!

Installing Libraries

This example also requires an additional Arduino MIDI libraries:

  1. Visit the Arduino MIDI Library repositories and download the entire repo to your local drive.

  2. Now, the library can be installed to the Arduino IDE. Open the Arduino IDE, and click sketch -> Include Library -> Add .ZIP Library, and choose the Seeed_Arduino_LCD file that you've have just downloaded.


Obtaining Results

In this case, Wio Terminal is connected to my Macbook and use Audio MIDI Setup app that comes along with macOS to test. You can also see the serial data from the serial monitor in Arduino IDE. If you have a MIDI Device available, then use that instead for more realistic scenario!

Complete Code

For more fucntionality, please refer to the TinyUSB libraries.

#include <Arduino.h>
#include <Adafruit_TinyUSB.h>
#include <MIDI.h>

// USB MIDI object
Adafruit_USBD_MIDI usb_midi;

// Create a new instance of the Arduino MIDI Library,
// and attach usb_midi as the transport.

// Variable that holds the current position in the sequence.
uint32_t position = 0;

// Store example melody as an array of note values
byte note_sequence[] = {

void setup()

// Initialize MIDI, and listen to all MIDI channels
// This will also call usb_midi's begin()

// Attach the handleNoteOn function to the MIDI Library. It will
// be called whenever the Bluefruit receives MIDI Note On messages.

// Do the same for MIDI Note Off messages.


// wait until device mounted
while( !USBDevice.mounted() ) delay(1);

void loop()
static uint32_t start_ms = 0;
if ( millis() - start_ms > 266 )
start_ms += 266;

// Setup variables for the current and previous
// positions in the note sequence.
int previous = position - 1;

// If we currently are at position 0, set the
// previous position to the last note in the sequence.
if (previous < 0) {
previous = sizeof(note_sequence) - 1;

// Send Note On for current position at full velocity (127) on channel 1.
MIDI.sendNoteOn(note_sequence[position], 127, 1);

// Send Note Off for previous note.
MIDI.sendNoteOff(note_sequence[previous], 0, 1);

// Increment position

// If we are at the end of the sequence, start over.
if (position >= sizeof(note_sequence)) {
position = 0;

// read any new MIDI messages;

void handleNoteOn(byte channel, byte pitch, byte velocity)
// Log when a note is pressed.
Serial.printf("Note on: channel = %d, pitch = %d, velocity - %d", channel, pitch, velocity);

void handleNoteOff(byte channel, byte pitch, byte velocity)
// Log when a note is released.
Serial.printf("Note off: channel = %d, pitch = %d, velocity - %d", channel, pitch, velocity);
Loading Comments...