Adding Shift Register Input to this Code

Hello,
I’m trying to expand an existing project using several 74hc165 shift registers to give me more buttons (24 total) in the project. My existing project uses digital input buttons to activate a string of values for MIDI notes and play them to an external controller. It works extremely well for my purpose and would like to stick with it if at all possible but I could do something else. This is my first experiment with shift registers so its possible I’m completely missing something there was well. I can get the serial information off the shift register I just don’t know what to do with it. Here is my code of the existing project-

#define NUM_BUTTONS 5

const uint8_t button1 = 2;
const uint8_t button2 = 3;
const uint8_t button3 = 4;
const uint8_t button4 = 5;
const uint8_t button5 = 6;

const uint8_t buttons[NUM_BUTTONS] = {button1, button2, button3, button4, button5};
const byte notePitches[NUM_BUTTONS] = {1, 20, 3, 44, 5};

uint8_t notesTime[NUM_BUTTONS];
uint8_t pressedButtons = 0x00;
uint8_t previousButtons = 0x00;
uint8_t intensity;

void setup()
{
  Serial.begin(31250); //Standard=9600, Midi=31250
  for (int i = 0; i < NUM_BUTTONS; i++)
  pinMode (buttons[i], INPUT_PULLUP);
}

void loop()
{
  readButtons ();
  playNotes ();
}

void readButtons ()
{
  for (int i=0; i < NUM_BUTTONS; i++)
  {
    if (digitalRead(buttons[i] ==LOW))
    {
      bitWrite(pressedButtons, i, 1);
      delay(50);
    }
    else
      bitWrite(pressedButtons, i, 0);
  }
}

void playNotes()
{
  for (int i = 0; i < NUM_BUTTONS; i++)
  {
    if (bitRead(pressedButtons, i) != bitRead(previousButtons, i))
    {
      if (bitRead(pressedButtons, i))
      {
        bitWrite(previousButtons, i, 1);
        midiOUT(0x90, notePitches[i], 127); //Note On
      }
      else
      {
        bitWrite(previousButtons, i, 1);
        midiOUT(0x80, notePitches[i], 127);//Note Off
      }
    }
  }
}

void midiOUT (int command, int value1, int value2)
{
  Serial.write(command);
  Serial.write(value1);
  Serial.write(value2);
}

In can return serial information to the monitor but can’t figure out how to use it in the context of my existing code. I’ve tried to add the returned info as a button but I’m not sure thats possible even though it’s the way I’d really like to go. I’m open to changing it if needed but just need a nudge in the right direction.

Thanks

I can get the serial information off the shift register I just don't know what to do with it.

Once you have a value from the shift register(s) in a variable you can determine the value of each bit using bitRead() or other techniques to determine whether a particular button was pressed.