updated example to do some more prints
void setup() {
Serial.begin(115200);
while(!Serial);
delay(1000);
Serial.println("\nSSD1306 LCD test");
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
Serial.println("\nSSD1306 LCD found OK");
if the I2C address is incorrect (e.g.0x3D) the serial monitor displays
SSD1306 LCD test
SSD1306 LCD found OK
as though all is OK and LCD found (nothing appears on the LCD)
i.e. I would have expected it to display and go into endless loop
Serial.println(F("SSD1306 allocation failed"));