Skip to main content Skip to local navigation

MIDI 1.0 Example using RP2350 + Arduino

RP2350 Microcontroller by Seeed Studio
RP2350 Microcontroller by Seeed Studio

So, I've got a Seeed Studio Xiao RP2350. It's a minimalist RP2350 microcontroller board. Can it use its USB-C port to output MIDI 1.0 notes over USB? Yes. Here's how... I...

  1. Set up my Arduino 1.8 IDE to support the RP2350 by updating its libraries
  2. Plugged in the RP2350 and made sure that it was recognized by the Arduino IDE.
  3. Found an example MIDI 1.0 program in the Arduino tutorial docs (https://docs.arduino.cc/tutorials/generic/midi-device/)
  4. Modified that to output two notes.

The code that I used is:

/*
  Modification of 2015 canned MIDI 1.0 example by 
  Arturo Guadalupi <a.guadalupi@arduino.cc>
   http://www.arduino.cc/en/Tutorial/MidiDevice
*/

#include "MIDIUSB.h"
void setup() {
}

void loop() {
      noteOn(0, 100, 110);
        MidiUSB.flush();
        delay(500);
        noteOff(0, 100, 110);
        MidiUSB.flush();
      delay(500);
        
      noteOn(0, 80, 110);
        MidiUSB.flush();
        delay(500);
        noteOff(0, 80, 110);
        MidiUSB.flush();
      delay(500);
}


// First parameter is the event type (0x09 = note on, 0x08 = note off).
// Second parameter is note-on/note-off, combined with the channel.
// Channel can be anything between 0-15. Typically reported to the user as 1-16.
// Third parameter is the note number (48 = middle C).
// Fourth parameter is the velocity (64 = normal, 127 = fastest).

void noteOn(byte channel, byte pitch, byte velocity) {
  midiEventPacket_t noteOn = {0x09, (uint8_t)(0x90 | channel), pitch, velocity};
  MidiUSB.sendMIDI(noteOn);
}

void noteOff(byte channel, byte pitch, byte velocity) {
  midiEventPacket_t noteOff = {0x08, (uint8_t)(0x80 | channel), pitch, velocity};
  MidiUSB.sendMIDI(noteOff);
}

It compiles and loads on to the RP2350. I verified it using MTSL:

Two notes on the RP2350 and MTSL

Simple and easy.


a pen

James Andrew Smith is a Professional Engineer and Associate Professor in the Electrical Engineering and Computer Science Department of York University’s Lassonde School, with degrees in Electrical and Mechanical Engineering from the University of Alberta and McGill University.  Previously a program director in biomedical engineering, his research background spans robotics, locomotion, human birth, music and engineering education. While on sabbatical in 2018-19 with his wife and kids he lived in Strasbourg, France and he taught at the INSA Strasbourg and Hochschule Karlsruhe and wrote about his personal and professional perspectives.  James is a proponent of using social media to advocate for justice, equity, diversity and inclusion as well as evidence-based applications of research in the public sphere. You can find him on Twitter.  You can find him on BlueSky. Originally from Québec City, he now lives in Toronto, Canada.