Unable to get the mcp23017 inputs to show in my code i want the 3 modules to be added to this code showing the inputs the same as the 32 on the mega (

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_MCP23X17.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1

Adafruit_MCP23X17 mcp1;
Adafruit_MCP23X17 mcp2;
Adafruit_MCP23X17 mcp3;
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

const int numButtons = 64; // Number of buttons
const int buttonPins[numButtons] = {
22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
}; // Pins for buttons

void setup() {
Wire.begin();
// Initialize MCP23017 modules
mcp1.begin_I2C(0x20); // Address 0
mcp2.begin_I2C(0x21); // Address 1
mcp3.begin_I2C(0x22); // Address 2

// Configure pins as INPUT
for (int i = 0; i < numButtons; i++) {
    mcp1.pinMode(i, INPUT);
    mcp2.pinMode(i, INPUT);
    mcp3.pinMode(i, INPUT);
}

Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();

for (int i = 0; i < numButtons; i++) {
    pinMode(buttonPins[i], INPUT_PULLUP);
}

}

void loop() {
// Read input states and handle accordingly
// Example: Check if MCP23017-1 pin 33 (GPIO 0) is LOW or HIGH
int state1 = mcp1.digitalRead(0);
if (state1 == LOW) {
// Handle button press on MCP23017-1 pin 33
// ...
}

// Similar handling for other pins on MCP23017-2 and MCP23017-3

display.clearDisplay();
display.setTextSize(6);
display.setTextColor(SSD1306_WHITE);

for (int i = 0; i < numButtons; i++) {
    int buttonState = digitalRead(buttonPins[i]);
    if (buttonState == LOW) {
        display.setCursor(15, 15);
        display.print("");// Text before Number
        display.print(i + 1);
        display.println(""); // Text after Number
    }
}

display.display();

delay(100); // Adjust delay as needed

}

Welcome to the Arduino forum, @sandhurstboy !
Please take the time to read

a bit more carefully, as your use of code tags is flawed. I haven't the ability to clean it up for you, so it's up to you. Try this:
In the Arduino IDE, with the code you wish to post, press ctrl-T.
That will properly format the code, for easy reading.
Then, press ctrl-shift-C to copy the code COMPLETE WITH FORMATTING for the forum,
Then, in a new message, press ctrl-V. That will insert your code, with forum formatting.

Now. Instead of putting your problem statement in the Title of the post, please write a short paragraph explaining what you're doing, and what the code is/is not doing. If you need to, copy output from the Serial Monitor into another code block, and explain what it is you want.

Thanks!

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_MCP23X17.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1

Adafruit_MCP23X17 mcp1;
Adafruit_MCP23X17 mcp2;
Adafruit_MCP23X17 mcp3;
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

const int numButtons = 64;  // Number of buttons
const int buttonPins[numButtons] = {
  22,
  23,
  24,
  25,
  26,
  27,
  28,
  29,
  30,
  31,
  32,
  33,
  34,
  35,
  36,
  37,
  38,
  39,
  40,
  41,
  42,
  43,
  44,
  45,
  46,
  47,
  48,
  49,
  50,
  51,
  52,
  53,
  54,
};  // Pins for buttons

void setup() {
  Wire.begin();
  // Initialize MCP23017 modules
  mcp1.begin_I2C(0);  // Address 0
  mcp2.begin_I2C(1);  // Address 1
  mcp3.begin_I2C(2);  // Address 2

  // Configure pins as INPUT
  for (int i = 0; i < numButtons; i++) {
    mcp1.pinMode(i, INPUT);
    mcp2.pinMode(i, INPUT);
    mcp3.pinMode(i, INPUT);
  }

  Serial.begin(9600);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();

  for (int i = 0; i < numButtons; i++) {
    pinMode(buttonPins[i], INPUT_PULLUP);
  }
}

void loop() {
  // Read input states and handle accordingly
  // Example: Check if MCP23017-1 pin 33 (GPIO 0) is LOW or HIGH
  int state1 = mcp1.digitalRead(0);
  if (state1 == LOW) {
    // Handle button press on MCP23017-1 pin 33
    // ...
  }

  // Similar handling for other pins on MCP23017-2 and MCP23017-3

  display.clearDisplay();
  display.setTextSize(6);
  display.setTextColor(SSD1306_WHITE);

  for (int i = 0; i < numButtons; i++) {
    int buttonState = digitalRead(buttonPins[i]);
    if (buttonState == LOW) {
      display.setCursor(15, 15);
      display.print("");  // Text before Number
      display.print(i + 1);
      display.println("");  // Text after Number
    }
  }

  display.display();

  delay(100);  // Adjust delay as needed
}

i want to display the status of 64 buttons on the ssd1306 OLED, 32 work that are on the mega 22-32 i have added 3 mcp23017 modules and want their 48 inputs to do the same displaying 33-86 on OLED i have linked up the sca and sda and taken to 5v with a 10k resistor reset on all 3 modules is linked to 5v. and a0,a1,a2 all linked to ov

those are address pins. To use 3 modules, they need to be set individually to different addresses. For example, one module all set to 0V, one module set 0/0/1, one module set 0/1/0. IF you did that, you should find three modules at address 0x20, 0x21, and 0x22. Use the I2C scanner that comes with the IDE, it's more than sufficient for locating MCP23017 if they're configured right.

Using the IDE's scanner means you don't have to get your code right, that's an independent step once we know the hardware is out there.

Thanks for your help i did that and the scanner picks up 0x22,0x24 and 0x3C which i think is the OLED but i do not get the input pins on any of the modules displaying a number

So, 3 MCP wired, but only two appear (plus the OLED, yes, 0x3C is likely correct) - then you're not out of the woods yet. Look at your soldering, or jumpers, to see if one is unique and two are still same.

Sorry bad connection on one module i now have 0x20,0x22,0x24, and 0x3C but nothing on display when i press button (pulls to ground)

Shouldn't those then be

 mcp1.begin_I2C(0x20);  // Address 0
 mcp2.begin_I2C(0x21);  // Address 1
 mcp3.begin_I2C(0x22);  // Address 2

or, the addresses your scanner is finding?

And this is wrong, because each MCP only has 16 pins, so i should run from 0 to 15.
There's more wrong with your code, but I'm out of time. Sorry.
Someone else can jump on this.

OK thanks for your help i will look out for further help thank again