What's new
Here's a sample code to get you started with using an OLED 0.9 display with an Arduino Nano:

Code:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

void setup() {
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
}

void loop() {
  display.clearDisplay();
  display.setCursor(0,0);
  display.println("Hello World!");
  display.display();
  delay(1000);
}

This code uses the Adafruit_SSD1306 library to control the OLED display. It first initializes the display in the setup() function and sets some display settings such as text size and color. In the loop() function, it clears the display, writes "Hello World!" to it, and displays it. It then waits for 1 second before repeating the process.

Note that you may need to adjust the I2C address of the display and the pin used for the reset if they differ from the default values used in this code.
 
Here is an example code for using a 0.9 inch OLED display with Arduino:

Code:
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>

#define SCREEN_WIDTH 64
#define SCREEN_HEIGHT 48

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
  Wire.begin();
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.setTextColor(WHITE);
}

void loop() {
  display.clearDisplay();
  display.setTextSize(1);
  display.setCursor(0,0);
  display.println("Hello, world!");
  display.display();
}

This code uses the Adafruit_SSD1306 and Adafruit_GFX libraries to communicate with the OLED display. SCREEN_WIDTH and SCREEN_HEIGHT are defined as 64 and 48 respectively for a 0.9 inch OLED display. In the setup() function, the display is initialized and the text color is set to white. In the loop() function, the display is cleared and some text is printed. The display is then updated with display.display().
 

Similar threads

Back
Top