I need help my Oled display is not turning on i even though i bought it yesterday and it was working fin then but once i took it out and after a day put it back it won't turn on or detect with an i2c address checker and i dont got money to buy a new one. heres the image and code
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width
#define SCREEN_HEIGHT 32 // OLED display height
// Initialize the OLED display (without reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup() {
// Start I2C and Serial
Wire.begin();
Serial.begin(9600);
Serial.println("\nI2C Scanner");
// Initialize OLED display
if (!display.begin(0x3C, SCREEN_WIDTH, SCREEN_HEIGHT)) { // Use 0x3C as the I2C address
Serial.println("OLED initialization failed!");
for (;;); // Halt execution
}
// Clear display and set initial text
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.println("I2C Scanner");
display.display();
bool deviceFound = false; // Flag to track if any device is found
for (byte address = 1; address < 127; ++address) {
Wire.beginTransmission(address);
if (Wire.endTransmission() == 0) {
Serial.print("I2C device found at address 0x");
if (address < 16) Serial.print("0");
Serial.println(address, HEX);
// Update OLED display
display.print("Found: 0x");
if (address < 16) display.print("0");
display.println(address, HEX);
display.display();
deviceFound = true;
delay(10);
}
}
if (!deviceFound) {
Serial.println("No I2C devices found.");
display.println("No I2C devices found.");
display.display();
}
Serial.println("Done.");
display.println("Scan Complete.");
display.display();
}
void loop() {
// No actions required in loop
}
