Arduino MIDIUSB won't stop crashing VirtualDJ

Hi there,

I've decided to make my own MIDI controller for the Virtual DJ program. For this I first bought the Arduino Pro Mico and wrote a test program. I tested it with FL Studio and after a few problems that I was able to solve, it worked perfectly. I immediately opened Virtual DJ to test it there, but every time I connect the Arduino Pro Mico it just goes white and dosn't respond anymore until I unplug the arduino again.

I've already tried:

  • Use another pro micro
  • Testing on my laptop => same error
  • Rewrite the program

I also tried to load a completely different program on it and then it didn't crash. I think every time I use the "MIDIUSB.h" library, this error occurs.

Here is the code I'm currently trying to get to work:

#include "MIDIUSB.h"

const int FADER = 9;        //  Pitch Fader pin
int analogval = 0;

byte midiCh = 0x01;
byte cc = 0x01;

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

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

void setup() {
  //Serial.begin(9200);
}


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

void loop() {  
  int analogval = analogRead(FADER);
  
  controlChange(midiCh, cc, map(analogval, 0, 1023, 0, 127));   // Channel 6, Control Change 016, Fader value
  MidiUSB.flush();
  
  delay(150);
}

I also get this warning every time I upload the sketch:

Can someone help me? Thanks in advance.

You're overwhelming the software with a constant stream of MIDI message. You need to do some filtering and hysteresis, and only send a message when that filtered value changes.

There are libraries that do this for you, see e.g. Control Surface: Control-Change-Potentiometer.ino

I already ran into that problem. I managed to fix both things now. Turns out the Arduino pro micro is actually a Leonardo and if I upload the sketch as micro it won‘t work at all.

It's not. You should use the right Arduino Core: Pro Micro & Fio V3 Hookup Guide - SparkFun Learn

The Micro and Pro Micro are different boards.

I know the micro and pro micro are different from each other. I selected the Leonardo in the options because the first time I hooked up the board it said „Arduino Leonardo“.

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