arduino-libraries / MIDIUSB

A MIDI library over USB, based on PluggableUSB
GNU Lesser General Public License v2.1
494 stars 89 forks source link

Windows Device Manager shows error: "This device cannot start. (Code 10)" #99

Closed ccarmatic closed 1 year ago

ccarmatic commented 1 year ago

I am using Windows 11 and an Arduino Zero

this is my code, the version of MIDIUSB is 1.0.5

#include <Arduino.h>
#include "MIDIUSB.h"

unsigned long prevtime = 0;
unsigned long time = 0;
int prevvalue = 0;

void controlChange(byte channel, byte control, byte value)
{
  midiEventPacket_t event = {0x0B, 0xB0 | channel, control, value};
  MidiUSB.sendMIDI(event);
  // MidiUSB.flush();
}

void setup()
{
  prevvalue = analogRead(A0) / 8;
}

void loop()
{
  digitalWrite(LED_BUILTIN, LOW);
  time = millis() - prevtime;
  if (time > 50)
  {
    digitalWrite(LED_BUILTIN, HIGH);
    uint8_t value = analogRead(A0) / 8;
    if (abs(value - prevvalue) > 5)
    {
      prevvalue = value;
      controlChange(1, 1, value);
      MidiUSB.flush();
    }

    prevtime = millis();
  }
}

I flash the code to the Zero using its debug USB port and I can verify that it is working because the builtin LED flashes correctly and the transmit LED lights up when I turn the trimpot connected to A0

But when I connect the Zero with the native port (which MIDIUSB uses), I see this in Windows Device Manager: image

This device cannot start. (Code 10)

A device which does not exist was specified.

an entry with the Arduino Zero name at COM7 which 'does not exist' to Windows, and a 'USB Serial Device' at COM6

The Arduino Zero is not being detected as a MIDI device , but Arduino IDE can access COM6 to upload sketches and open the serial monitor on the native USB port

If I upload any other sketch , which does not contain MIDIUSB, everything is normal in Windows, in Arduino IDE, and on the Arduino Zero. This leads me to believe that the fault lies in MIDIUSB

per1234 commented 1 year ago

@ccarmatic's post about the problem on Arduino Forum:

https://forum.arduino.cc/t/arduino-zero-midiusb-problem/1157189

Related:

ccarmatic commented 1 year ago

Hello, I have tried the uninstall and reinstall drivers method without success - until I closed the Arduino IDE and did it again - the IDE was preventing Windows from deleting the necessary drivers