MIDI CONTROLLER

MIDI.begin overrides the baud rate set by Serial.begin. The proper way to set the baud rate is:

MIDI library baud rate setting:

---



```
#include <MIDI.h>

struct MySettings : public midi::DefaultSettings {
  static const long BaudRate = 115200;
};

MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial, MIDI, MySettings)

void setupcolor=#000000[/color] {
  MIDI.begincolor=#000000[/color];
}

void loopcolor=#000000[/color] {
  // put your main code here, to run repeatedly:
}
```

|

And like Grumpy_Mike said, your logic is very strange.

If you want to do it the easy way, take a look at my MIDI Controller library.
The following code replaces your entire sketch:

MIDI Controller code:

---



```
#include <MIDI_Controller.h> // Include the library

HairlessMIDI_Interface midi;

DigitalCC buttons[] = {
 {6, 105, 1}, // pin 6, controller 105, channel 1
 {7, 106, 1}
}

void setupcolor=#000000[/color] {}

void loopcolor=#000000[/color] {
 // Refresh the buttons (check whether a button's state has changed since last time, if so, send it over MIDI)
 MIDI_Controller.refreshcolor=#000000[/color];
}
```

|

Pieter