OLED display static

hello this is the code of my program, it is directly connected to the 3,3v and gnd of an arduino uno

#include <Adafruit_SSD1306.h>
#include <splash.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET     4
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup() {
  // put your setup code here, to run once:
  
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
    display.clearDisplay();                                 
    display.setTextSize(2);                                   
    display.setTextColor(WHITE); 
    display.setCursor(0,0);                
    display.println("Avvio");
}

void loop() {
  // put your main code here, to run repeatedly:
display.clearDisplay();
display.println("AVVIO");
}

it only displays static black and white noise

it is directly connected to the 3,3v and gnd of an arduino uno

You need more connections than that!

Also, WHAT screen do you have? post a link to the datasheet.

you are also missing
display.display();

missdrew:
You need more connections than that!

Also, WHAT screen do you have? post a link to the datasheet.

you are also missing
display.display();

The oled screen is obviously connected through i2c ports not only to gnd and 3.3v
Now that i put display.display(); in the setup it stopped displaying the static noise and started displaying adafruit industries logo but its still not printing my string of characters

The oled screen is obviously connected through i2c ports not only to gnd and 3.3v

Not obviously! I can't see your wiring and you make no mention of it.

also you need the display.display(); after

display.println("AVVIO");

Run all the Adafruit_SSD1306 library examples first. Before you even think of writing your own code.

Choose the example that is nearest to your project requirements.
Save the example to your project name.
Adapt the code to suit your needs in small stages. Test at every step.

You will soon see how the library functions work. And how the logic "flows".
Drawing a FlowChart on paper is a good design strategy.

Incidentally, you need display() whenever you want to show the new picture. e.g. at the end of loop()
And whenever you want to print text, you must setCursor() to keep the text on the screen. Otherwise it would soon get "printed" off the bottom of the screen.

David.

I assume the <splash.h> contains the Adafruit logo. So teh logo is dsiplayed and then the sketch fails. Very interesting!
The U8g2 lib provides more opportunity to run SSD1306 OLEDS than the Adafruit library does. I suggest here that you run some tests with u8g2.

This topic was automatically closed after 120 days. New replies are no longer allowed.