Computer not recognizing arduino due as MIDI device

Hello. I made a project where the Arduino behaves like a midi device and reads notes from the computer. as soon as it sees a note it applies voltage to one of the pins. but the problem is that the computer does not recognize the native port as midi. it sees it as a serial port. on windows 10 it sees it as bosse drive. I used the MIDIUSB library.

#include <MIDIUSB.h>

// Пины для светодиодов или других устройств, которые будут управляться
const int ledPins[] = {22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
const int numLeds = sizeof(ledPins) / sizeof(ledPins[0]);

// Начальная нота C4 (60 в стандартном MIDI)
const int firstNote = 60;

// Время включения пина в миллисекундах
const unsigned long onTime = 150;

void setup() {
  // Устанавливаем все пины как выходы
  for (int i = 0; i < numLeds; i++) {
    pinMode(ledPins[i], OUTPUT);
    digitalWrite(ledPins[i], LOW); // Изначально выключаем все
  }
}

void loop() {
  midiEventPacket_t rx;
  // Читаем MIDI-сообщение
  rx = MidiUSB.read();

  // Проверяем, является ли это сообщение нотой
  if (rx.header == 0x09 || rx.header == 0x08) { // Note On or Note Off
    int note = rx.byte1 & 0x7F; // Нота
    int velocity = rx.byte2 & 0x7F; // Скорость

    // Проверяем, попадает ли нота в диапазон привязанных пинов
    if (note >= firstNote && note < firstNote + numLeds) {
      int pinIndex = note - firstNote;
      if (rx.header == 0x09 && velocity > 0) { // Note On
        digitalWrite(ledPins[pinIndex], HIGH); // Включаем пин
        delay(onTime); // Задержка 150 миллисекунд
        digitalWrite(ledPins[pinIndex], LOW); // Выключаем пин
      }
    }
  }
}

solved, i just need to press reset button after connecting to pc

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.