0.96吋OLED基本顯示-ESP32
0.96吋OLED基本顯示-ESP32
OLED||ESP32
-----------------
VCC----3V3
GND----GND
SCL-----D22
SDA----D21
函式參考
須下載及匯入以下函式庫
程式碼
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GrayOLED.h>
#include <Wire.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup(){
Serial.begin(115200);
display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS, OLED_RESET);
}
void loop(){
display.clearDisplay();
display.setCursor(0, 0);
display.setTextSize(1);
display.setTextColor(BLACK, WHITE);
display.println("Hello!");
display.setCursor(0, 16);
display.setTextSize(2);
display.setTextColor(WHITE);
display.println("ESP32");
display.setTextSize(3);
display.setCursor(0, 32);
display.println("Arduino");
display.display();
}
留言
張貼留言