LEDs off when I press the switch, turning them on again press again

I managed to get my LED’s hooked up and programmed to separate pins than what my switches are (switches on pins 3, 4, 5, 6 - LEDs on 8, 9, 10, 11) but I want the led to stay off when I hit the switch(es) once, and come on again when I hit the switch(es) a second time - like an indicator light to let me know that my parameter is active or not. I have searched for hours and tried several different things… buttonstates, flipflop commands a bunch of other stuff. I can’t seem to code this! Any ideas? Here is my code so far:

#include <MIDI.h>
#include "Controller.h"




MIDI_CREATE_DEFAULT_INSTANCE();

byte NUMBER_BUTTONS = 4;
byte NUMBER_POTS = 0;
byte NUMBER_MUX_BUTTONS = 0;
byte NUMBER_MUX_POTS = 0;
Pot *POTS[] {};

//***DEFINE DIRECTLY CONNECTED BUTTONS*******************************
//Button (Pin Number, Command, Note Number, Channel, Debounce Time)
//** Command parameter 0=NOTE  1=CC  2=Toggle CC **
Button BU1(3, 2, 28, 1, 5 );
Button BU2(4, 2, 36, 1, 5 );
Button BU3(5, 2, 50, 1, 5 );
Button BU4(6, 1, 64, 1, 5 );
Button *BUTTONS[] {&BU1, &BU2, &BU3, &BU4};
Button *MUXBUTTONS[] {};

Pot *MUXPOTS[] {};
//*******************************************************************
int ledpin1 = 8;
int ledpin2 = 9;
int ledpin3 = 10;
int ledpin4 = 11;
int pushbutton1 = 3;
int pushbutton2 = 4;
int pushbutton3 = 5;
int pushbutton4 = 6;
int buttonState = 0;
static bool ledState = false; // LED is off by default
 

void setup() {
  MIDI.begin(MIDI_CHANNEL_OFF);
  pinMode(ledpin1,OUTPUT);
  pinMode(ledpin2,OUTPUT);
  pinMode(ledpin3,OUTPUT);
  pinMode(ledpin4,OUTPUT);
  pinMode(pushbutton1,INPUT_PULLUP); // Provide pullup
  pinMode(pushbutton2,INPUT_PULLUP); // Provide pullup
  pinMode(pushbutton3,INPUT_PULLUP); // Provide pullup
  pinMode(pushbutton4,INPUT_PULLUP); // Provide pullup
}

void loop() {
  if (NUMBER_BUTTONS != 0) updateButtons();
  if (NUMBER_POTS != 0) updatePots();
  if (NUMBER_MUX_BUTTONS != 0) updateMuxButtons();
  if (NUMBER_MUX_POTS != 0) updateMuxPots();
    if((digitalRead(pushbutton1) == LOW) && ledState) // led is off when parameter deactivated
        delay(10); // wait for 10 ms
        
  { 
    digitalWrite(ledpin1, LOW);
    ledState = false;
  }
  if((digitalRead(pushbutton1) == LOW) && !ledState) // led is on when parameter is activated
  {         
    digitalWrite(ledpin1, HIGH);
     delay(50); // wait for 50 ms
    ledState = true;
  }

}


//*****************************************************************
void updateButtons() {

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

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

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

  // Cycle through Mux Button array
  for (int i = 0; i < NUMBER_MUX_BUTTONS; i = i + 1) {

    MUXBUTTONS[i]->muxUpdate();
    byte message = MUXBUTTONS[i]->getValue();

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

I think the relevant section is in the void loop. Any ideas?

Have a look at StateChangeDetect, and every new press, change a boolean flag (say ledStatus) from what it is, to the other state. Then write that state to the led.

ledStatus = !ledStatus; // the ! means "not"
...
digitalWrite(thePin, ledStatus;)

(I see you use input pullup, which is good. The StateChangeDetect example uses pull downs, so you will need to reverse the logic, since you will get a low for a press.)

In other words, no matter what you do with your hardware, your idea won't work without the corresponding software suggested by neiklot.

.