I have a sketch that works perfectly with the Arduino r4 and Giga R1 but when I try to send a message to the waveshare 1.5 inch white display using the SSD1327 with the Elegoo Mega with the Atmega 2560 chip (ATMEGA2560 16U-TH 355E3F 23424GD)and even the Keyestudio with the Atmega chip neither board will print to the oled display. Each board can see the hardware (using I2C) scanner. Here follows the sketch:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1327.h>
// Define the I2C address of the OLED
#define OLED_I2C_ADDRESS 0x3D
// Create SSD1327 display object for I2C
Adafruit_SSD1327 display(128, 128, &Wire, -1); // -1 means no reset pin is used
void setup() {
// Initialize serial communication for debugging
Serial.begin(9600);
Serial.println("Initializing SSD1327 OLED...");
// Set I2C clock speed (100 kHz for compatibility)
Wire.begin();
Wire.setClock(100000); // Reduce I2C speed to 100 kHz if necessary
// Initialize the OLED display
if (!display.begin(SSD1327_I2C_ADDRESS, OLED_I2C_ADDRESS)) {
Serial.println("SSD1327 OLED initialization failed!");
while (1); // Halt if initialization fails
}
Serial.println("SSD1327 OLED initialized successfully!");
// Clear the display and show a test message
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1327_WHITE);
display.setCursor(0, 0);
display.println("Hello, I2C!");
display.println("Arduino Mega");
display.display();
delay(2000);
// Draw a test shape
display.clearDisplay();
display.drawRect(10, 10, 108, 108, SSD1327_WHITE); // Draw rectangle
display.fillCircle(64, 64, 20, SSD1327_WHITE); // Draw filled circle
display.display();
}
void loop() {
}
I am using 4.7k pull up resistors on the sda and scl lines.
I am not sure why this is happening but assistance to resolve it would be welcome. I did a search on the forum and found one case of this but with no resolution.
Regards in advance

