Advertisement
hwthinker

TTGO ESP32 OLED - Demo

Dec 30th, 2018
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. /**
  2. The MIT License (MIT)
  3. Copyright (c) 2018 by ThingPulse, Daniel Eichhorn
  4. Copyright (c) 2018 by Fabrice Weinberg
  5. Modified 2018 by HwThinker for TTGO ESP32 OLED Board
  6. ref: https://gist.github.com/gabonator/402e09eb1b5afce1e7be228483138071
  7. */
  8.  
  9. #include <Wire.h> // Only needed for Arduino 1.6.5 and earlier
  10. #include "SSD1306Wire.h" // legacy include: `#include "SSD1306.h"`
  11.  
  12. // Initialize the OLED display using Wire library
  13. SSD1306Wire display(0x3c, OLED_SDA, OLED_SCL); // OLED_SDA=4, OLED_SCL=15
  14.  
  15. void setup() {
  16. pinMode(LED_BUILTIN, OUTPUT);
  17. pinMode(16, OUTPUT);
  18. digitalWrite(16, LOW); // set GPIO16 low to reset OLED
  19. delay(50);
  20. digitalWrite(16, HIGH); // while OLED is running, must set GPIO16 in high、
  21.  
  22. Serial.begin(115200);
  23. Serial.println();
  24.  
  25. // Initialising the UI will init the display too.
  26. display.init();
  27. display.flipScreenVertically();
  28. display.setFont(ArialMT_Plain_10);
  29. // clear the display
  30. display.clear();
  31. }
  32.  
  33.  
  34. void loop() {
  35. display.setTextAlignment(TEXT_ALIGN_LEFT);
  36. display.setFont(ArialMT_Plain_10);
  37. display.drawString(0, 0, "TTGO ESP32 OLED");
  38. display.display();
  39. digitalWrite(LED_BUILTIN, HIGH);
  40. delay(1000);display.clear();
  41.  
  42. display.setFont(ArialMT_Plain_16);
  43. display.drawString(0, 10, "HwThinker");
  44. display.display();
  45. digitalWrite(LED_BUILTIN, LOW);
  46. delay(1000);display.clear();
  47.  
  48. display.setFont(ArialMT_Plain_24);
  49. display.drawString(0, 26, "inAction");
  50. display.display();
  51. digitalWrite(LED_BUILTIN, HIGH);
  52. delay(1000);
  53. display.clear();
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement