MIDI_Controller to USB MIDI_Controller

Hi,

I tried to adjust this code https://drive.google.com/file/d/0BwnVMB_6yujwR1dydVJ6MHJib2M/view

But it doesn’t work. I change the code on

void setup() {
Serial.begin(38400);
MIDI.begin(MIDI_CHANNEL_OFF);
}

MIDI_Controller_v1-3.ino (8.14 KB)

You cannot simply replace “MIDI” with “USB-MIDI” and expect it to work.

I’d recommend using the Control Surface library I maintain. The equivalent of your code using Control Surface would be:

[color=#5e6d03]#include[/color] [color=#434f54]<[/color][b][color=#d35400]Control_Surface[/color][/b][color=#434f54].[/color][color=#000000]h[/color][color=#434f54]>[/color]

[color=#434f54]// Instantiate the MIDI interface to use[/color]
[b][color=#d35400]USBMIDI_Interface[/color][/b] [color=#00979c]midi[/color][color=#000000];[/color]

[color=#5e6d03]using[/color] [color=#5e6d03]namespace[/color] [color=#000000]MIDI_Notes[/color][color=#000000];[/color]

[color=#434f54]// Instantiate an array of buttons that send out MIDI Note messages when pressed[/color]
[b][color=#d35400]NoteButton[/color][/b] [color=#000000]buttons[/color][color=#000000][[/color][color=#000000]][/color] [color=#434f54]=[/color] [color=#000000]{[/color]
  [color=#000000]{[/color][color=#000000]2[/color][color=#434f54],[/color] [color=#d35400]note[/color][color=#000000]([/color][color=#00979c]C[/color][color=#434f54],[/color] [color=#000000]4[/color][color=#000000])[/color][color=#000000]}[/color][color=#434f54],[/color] [color=#434f54]// pin number, MIDI address (note number)[/color]
  [color=#000000]{[/color][color=#000000]3[/color][color=#434f54],[/color] [color=#d35400]note[/color][color=#000000]([/color][color=#00979c]Db[/color][color=#434f54],[/color] [color=#000000]4[/color][color=#000000])[/color][color=#000000]}[/color][color=#434f54],[/color]
  [color=#000000]{[/color][color=#000000]4[/color][color=#434f54],[/color] [color=#d35400]note[/color][color=#000000]([/color][color=#00979c]D[/color][color=#434f54],[/color] [color=#000000]4[/color][color=#000000])[/color][color=#000000]}[/color][color=#434f54],[/color]
  [color=#000000]{[/color][color=#000000]5[/color][color=#434f54],[/color] [color=#d35400]note[/color][color=#000000]([/color][color=#00979c]Eb[/color][color=#434f54],[/color] [color=#000000]4[/color][color=#000000])[/color][color=#000000]}[/color][color=#434f54],[/color]
[color=#000000]}[/color][color=#000000];[/color]

[color=#00979c]void[/color] [color=#5e6d03]setup[/color][color=#000000]([/color][color=#000000])[/color] [color=#000000]{[/color]
  [color=#434f54]// Initialize everything[/color]
  [b][color=#d35400]Control_Surface[/color][/b][color=#434f54].[/color][color=#d35400]begin[/color][color=#000000]([/color][color=#000000])[/color][color=#000000];[/color]
[color=#000000]}[/color]

[color=#00979c]void[/color] [color=#5e6d03]loop[/color][color=#000000]([/color][color=#000000])[/color] [color=#000000]{[/color]
  [color=#434f54]// Continuously poll the inputs and send MIDI accordingly[/color]
  [b][color=#d35400]Control_Surface[/color][/b][color=#434f54].[/color][color=#5e6d03]loop[/color][color=#000000]([/color][color=#000000])[/color][color=#000000];[/color]
[color=#000000]}[/color]

The other inputs used in your sketch (potentiometers, multiplexers), and much more are supported as well. More info in the documentation.

Pieter