|
| 1 | +/********************************************************************* |
| 2 | + Adafruit invests time and resources providing this open source code, |
| 3 | + please support Adafruit and open-source hardware by purchasing |
| 4 | + products from Adafruit! |
| 5 | +
|
| 6 | + MIT license, check LICENSE for more information |
| 7 | + Copyright (c) 2019 Ha Thach for Adafruit Industries |
| 8 | + All text above, and the splash screen below must be included in |
| 9 | + any redistribution |
| 10 | +*********************************************************************/ |
| 11 | + |
| 12 | +// This sketch is enumerated as USB MIDI device with multiple ports |
| 13 | +// and how to set their name |
| 14 | + |
| 15 | +#include <Arduino.h> |
| 16 | +#include <Adafruit_TinyUSB.h> |
| 17 | +#include <MIDI.h> |
| 18 | + |
| 19 | +// USB MIDI object with 3 ports |
| 20 | +Adafruit_USBD_MIDI usb_midi(3); |
| 21 | + |
| 22 | +void setup() |
| 23 | +{ |
| 24 | + pinMode(LED_BUILTIN, OUTPUT); |
| 25 | + |
| 26 | +#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040) |
| 27 | + // Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040 |
| 28 | + TinyUSB_Device_Init(0); |
| 29 | +#endif |
| 30 | + |
| 31 | + // Set name for each cable, must be done before usb_midi.begin() |
| 32 | + usb_midi.setCableName(1, "Keyboard"); |
| 33 | + usb_midi.setCableName(2, "Drum Pads"); |
| 34 | + usb_midi.setCableName(3, "Lights"); |
| 35 | + |
| 36 | + usb_midi.begin(); |
| 37 | +} |
| 38 | + |
| 39 | +void loop() |
| 40 | +{ |
| 41 | + digitalWrite(LED_BUILTIN, HIGH); |
| 42 | + delay(1000); |
| 43 | + |
| 44 | + digitalWrite(LED_BUILTIN, LOW); |
| 45 | + delay(1000); |
| 46 | +} |
0 commit comments