hairless midi isn´t working properly

Hey, i just made a custom made loop station for my guitar, it works as a midi controller. The thing is that i have to press each button twice for it to send a signal, as shown in the attached picture. please give me a hand.

#include "MIDI.h"
#include "Controller.h"



struct HairlessMidiSettings : public midi::DefaultSettings
{
   static const bool UseRunningStatus = false;
   static const long BaudRate = 38400;
};
MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial, MIDI, HairlessMidiSettings);


byte NUMBER_BUTTONS = 9;
byte NUMBER_POTS = 0;
byte NUMBER_MUX_BUTTONS = 0;
byte NUMBER_MUX_POTS = 0;

Pot *POTS[] {};


Button BU1(2, 2, 102, 1, 5 );
Button BU2(3, 2, 103, 1, 5 );
Button BU3(4, 2, 104, 1, 5 );
Button BU4(5, 2, 105, 1, 5 );
Button BU5(6, 2, 106, 1, 5 );
Button BU6(7, 2, 107, 1, 5 );
Button BU7(8, 2, 108, 1, 5 );
Button BU8(9, 2, 109, 1, 5 );
Button BU9(11, 2, 110, 1, 5 );

Button *BUTTONS[] {&BU1, &BU2, &BU3, &BU4, &BU5, &BU6, &BU7, &BU8, &BU9};

Button *MUXBUTTONS[] {};

Pot *MUXPOTS[] {};

int pinButton = 12;
int LED = 10;
int stateLED = LOW;
int stateButton;
int previous = LOW;
long time = 0;
long debounce = 200;


void setup() {

  MIDI.begin();
  Serial.begin(38400);
  pinMode(pinButton, OUTPUT);
  pinMode(LED, OUTPUT);


 
}

void loop() {
  if (NUMBER_BUTTONS != 0) updateButtons();
  if (NUMBER_POTS != 0) updatePots();
  if (NUMBER_MUX_BUTTONS != 0) updateMuxButtons();
  if (NUMBER_MUX_POTS != 0) updateMuxPots();
 
    stateButton = digitalRead(pinButton); 
  if(stateButton == HIGH && previous == LOW && millis() - time > debounce) {
    if(stateLED == HIGH){
      stateLED = LOW;
    } else {
       stateLED = HIGH;
    }
    time = millis();
  }
  digitalWrite(LED, stateLED);
  previous == stateButton;
}


void updateButtons() {

  // Cycle through Button array
  for (int i = 0; i < NUMBER_BUTTONS; i = i + 1) {
    byte message = BUTTONS->getValue();

    if (message == 0) {
      switch (BUTTONS->Bcommand) {
        case 0:
          MIDI.sendNoteOn(BUTTONS->Bvalue, 127, BUTTONS->Bchannel);
          break;
        case 1: //CC
          MIDI.sendControlChange(BUTTONS->Bvalue, 127, BUTTONS->Bchannel);
          break;
        case 2: //Toggle
          if (BUTTONS->Btoggle == 0) {
            MIDI.sendControlChange(BUTTONS->Bvalue, 127, BUTTONS->Bchannel);
            BUTTONS->Btoggle = 1;
          }
          else if (BUTTONS->Btoggle == 1) {
            MIDI.sendControlChange(BUTTONS->Bvalue, 0, BUTTONS->Bchannel);
            BUTTONS->Btoggle = 0;
          }
          break;
      }
    }

    //  Button is not pressed
    if (message == 1) {
      switch (BUTTONS->Bcommand) {
        case 0:
          MIDI.sendNoteOff(BUTTONS->Bvalue, 0, BUTTONS->Bchannel);
          break;
        case 1:
          MIDI.sendControlChange(BUTTONS->Bvalue, 0, BUTTONS->Bchannel);
          break;
      }
    }
  }
}
void updateMuxButtons() {

  for (int i = 0; i < NUMBER_MUX_BUTTONS; i = i + 1) {

    MUXBUTTONS->muxUpdate();
    byte message = MUXBUTTONS->getValue();

    if (message == 0) {
      switch (MUXBUTTONS->Bcommand) {
        case 0:
          MIDI.sendNoteOn(MUXBUTTONS->Bvalue, 127, MUXBUTTONS->Bchannel);
          break;
        case 1:
          MIDI.sendControlChange(MUXBUTTONS->Bvalue, 127, MUXBUTTONS->Bchannel);
          break;
        case 2: //Toggle
          if (MUXBUTTONS->Btoggle == 0) {
            MIDI.sendControlChange(MUXBUTTONS->Bvalue, 127, MUXBUTTONS->Bchannel);
            MUXBUTTONS->Btoggle = 1;
          }
          else if (MUXBUTTONS->Btoggle == 1) {
            MIDI.sendControlChange(MUXBUTTONS->Bvalue, 0, MUXBUTTONS->Bchannel);
            MUXBUTTONS->Btoggle = 0;
          }
          break;
      }
    }
    if (message == 1) {
      switch (MUXBUTTONS->Bcommand) {
        case 0:
          MIDI.sendNoteOff(MUXBUTTONS->Bvalue, 0, MUXBUTTONS->Bchannel);
          break;
        case 1:
          MIDI.sendControlChange(MUXBUTTONS->Bvalue, 0, MUXBUTTONS->Bchannel);
          break;
      }
    }
  }
}
void updatePots() {
  for (int i = 0; i < NUMBER_POTS; i = i + 1) {
    byte potmessage = POTS->getValue();
    if (potmessage != 255) MIDI.sendControlChange(POTS->Pcontrol, potmessage, POTS->Pchannel);
  }
}
void updateMuxPots() {
  for (int i = 0; i < NUMBER_MUX_POTS; i = i + 1) {
    MUXPOTS->muxUpdate();
    byte potmessage = MUXPOTS->getValue();
    if (potmessage != 255) MIDI.sendControlChange(MUXPOTS->Pcontrol, potmessage, MUXPOTS->Pchannel);
  }
}

previous == stateButton;

Did you mean:

previous = stateButton;

This mistake is warned by the IDE. You should enable the warning setting to All.