hwthinker icon

TTGO ESP32 OLED - Demo

hwthinker | PRO | 12/31/18 02:59:12 AM UTC | 0 ⭐ | 577 👁️ | Never ⏰ | []
text |

1.55 KB

|

None

|

0 👍

/

0 👎

/**
   The MIT License (MIT)
   Copyright (c) 2018 by ThingPulse, Daniel Eichhorn
   Copyright (c) 2018 by Fabrice Weinberg
   Modified 2018 by HwThinker for TTGO ESP32 OLED Board
   ref: https://gist.github.com/gabonator/402e09eb1b5afce1e7be228483138071
*/
 #include <Wire.h>  // Only needed for Arduino 1.6.5 and earlier
#include "SSD1306Wire.h" // legacy include: `#include "SSD1306.h"`
 // Initialize the OLED display using Wire library
SSD1306Wire  display(0x3c, OLED_SDA, OLED_SCL); // OLED_SDA=4, OLED_SCL=15
 void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(16, OUTPUT);
  digitalWrite(16, LOW);    // set GPIO16 low to reset OLED
  delay(50);
  digitalWrite(16, HIGH); // while OLED is running, must set GPIO16 in high、
   Serial.begin(115200);
  Serial.println();
   // Initialising the UI will init the display too.
  display.init();
  display.flipScreenVertically();
  display.setFont(ArialMT_Plain_10);
  // clear the display
  display.clear();
}
  void loop() {
  display.setTextAlignment(TEXT_ALIGN_LEFT);
  display.setFont(ArialMT_Plain_10);
  display.drawString(0, 0, "TTGO ESP32 OLED");
  display.display();
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);display.clear();
   display.setFont(ArialMT_Plain_16);
  display.drawString(0, 10, "HwThinker");
  display.display();
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);display.clear();
   display.setFont(ArialMT_Plain_24);
  display.drawString(0, 26, "inAction");
  display.display();
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  display.clear();
}

Comments