microrobotics icon

D1 Mini 0.66 inch OLED display

microrobotics | PRO | 05/08/23 08:15:26 AM UTC | 0 ⭐ | 4399 👁️ | Never ⏰ | []
Arduino |

1.31 KB

|

None

|

0 👍

/

0 👎

/*
To use a 0.66-inch OLED display (64x48 resolution) with a D1 Mini board, you can use the "Adafruit_SSD1306" and "Adafruit_GFX" libraries. First, install these libraries through the Arduino Library Manager.
 
This code initializes the OLED display and prints "Hello, World!" on it. You can modify the text and the position of the text by changing the parameters in the display.print() and display.setCursor() functions, respectively.
 
Here's an example code to display "Hello, World!" on the 0.66-inch OLED display:
*/
 
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
 
// OLED display parameters
#define SCREEN_WIDTH 64
#define SCREEN_HEIGHT 48
#define OLED_RESET -1
#define I2C_ADDRESS 0x3C
 
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
 
void setup() {
  // Initialize the OLED display
  Wire.begin();
  if (!display.begin(SSD1306_SWITCHCAPVCC, I2C_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;);
  }
  display.display();
  delay(2000);
 
  // Clear the buffer
  display.clearDisplay();
 
  // Display text on the OLED
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  display.print(F("Hello, World!"));
  display.display();
}
 
void loop() {
  // Nothing to do in the loop
}
 

Comments