arduino MICRO Midi cc read for led

I was starting arduino project some weeks ago to build midi controller. I started with the arduino Uno following tutorial from NOTESandVOLTS…Everythings works fine and he had code for led where he define some led in digital port and led react when they reveive a cc message. I changed for arduino MICRO
and try to do exactly the same but with midiusb library.(i am not a good programmer).This code is not working on Micro but I don’t know how to start because all post about midi read for led are often confusing…

here is the code.of note and volts.

    MIDI CC Light Show
    by Notes and Volts

#include <MIDI.h>  // Add Midi Library
#include <MIDI_Controller.h> // Include the library

// Define labels for the 6 PWM pins
#define LEDPWM1 3
#define LEDPWM2 5
#define LEDPWM3 6
#define LEDPWM4 9
#define LEDPWM5 10
#define LEDPWM6 11

//Create an instance of the library with default name, serial port and settings

void setup() {
  //pinMode (LED, OUTPUT); // Set Arduino board pin 13 to output
  MIDI.begin(MIDI_CHANNEL_OMNI); // Initialize the Midi Library.
  // OMNI sets it to listen to all channels.. MIDI.begin(2) would set it
  // to respond to notes on channel 2 only.
  MIDI.setHandleControlChange(MyCCFunction); // This command tells the MIDI Library
  // the function you want to call when a Continuous Controller command
  // is received. In this case it's "MyCCFunction".

void loop() { // Main loop; // Continuously check if Midi data has been received.

// MyCCFunction is the function that will be called by the Midi Library
// when a Continuous Controller message is received.
// It will be passed bytes for Channel, Controller Number, and Value
// It checks if the controller number is within the 22 to 27 range
// If it is, light up the corresponding LED with the PWM brightness equal to the Value byte
void MyCCFunction(byte channel, byte number, byte value) {
  switch (number) {
    case 22:
      analogWrite(LEDPWM1, value * 2);
    case 23:
      analogWrite(LEDPWM2, value * 2);
    case 24:
      analogWrite(LEDPWM3, value * 2);
    case 25:
      analogWrite(LEDPWM4, value * 2);
    case 26:
      analogWrite(LEDPWM5, value * 2);
    case 27:
      analogWrite(LEDPWM6, value * 2);


I follow Exemple from MIDIUSBlibrary and i see that RX is reacting to cc message, good news…but i don’t figure out how to adapt this code to make what i need : 1st i don’t know where and how define some led to pin, then some pin to cc and 3nd I see that the rx is blink one time when receiving message but I want a constant led (I build a dj midi controller who needs to lights the led when a track is playing (by exemple) or when an effect is pushed) then it is a little bit like a toggle…here is the code that I find in Exemple…Thanks in advance for advice or way to solve my problems…

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

void noteOn(byte channel, byte pitch, byte velocity) {
  midiEventPacket_t noteOn = {0x09, 0x90 | 1, 27, velocity};

void noteOff(byte channel, byte pitch, byte velocity) {
  midiEventPacket_t noteOff = {0x08, 0x80 | 1, 27, velocity};
const uint8_t velocity = 0b1111111; // Maximum velocity (0b1111111 = 0x7F = 127)
const uint8_t C4 = 60;              // Note number 60 is defined as middle C in the MIDI specification
const uint8_t D4 = 61;
const uint8_t E4 = 62;
const uint8_t G4 = 63; 
const uint8_t H4 = 64; 
const uint8_t I4 = 65; 
const uint8_t J4 = 66; 
const uint8_t K4 = 67; 
// Create a new instance of the class 'Digital', called 'button', on pin 2, that sends MIDI messages with note 'C4' (60) on channel 1, with velocity 127
Digital button(2, C4, 1, velocity);
Digital button2(3, D4, 1, velocity);
Digital button3(4, E4, 1, velocity);
Digital button4(5, G4, 1, velocity);
Digital button5(6, H4, 1, velocity);
Digital button6(7, I4, 1, velocity);
Digital button7(8, J4, 1, velocity);

void setup() {Serial.begin(115200);}

void controlChange(byte channel, byte control, byte value) {
  midiEventPacket_t event = {0x0B, 0xB0 | 1, 27, value};
void loop() {
  midiEventPacket_t rx;
  do {
    rx =;
    if (rx.header != 0) {
      Serial.print(rx.header, HEX);
      Serial.print(rx.byte1, HEX);
      Serial.print(rx.byte2, HEX);
      Serial.println(rx.byte3, HEX);
  } while (rx.header != 0);
  // Refresh the button (check whether the button's state has changed since last time, if so, send it over MIDI)