This project uses an ESP32 to control an OLED display. The display shows words sequentially with specified delays.
Requirements
| Materials | Quantity |
|---|---|
| ESP32 | 1 |
| OLED Display (0.96 in, 128x64, IIC) | 1 |
| Breadboard | 1 |
| LED (soon) | 3 |
| M-F Jumper Wires | 4 |
Programming
I used the Arduino IDE with the ESP32 library.
Install the IDE from its official website
Also install the required library inside Arduino IDE:
Wire(included in Arduino Libary)
Adafruit GFX Library
Adafruit SSD1306
ESP32 Board Manager for Arduino:
https://dl.espressif.com/dl/package_esp32_index.json
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// modify the lyrics here --
String words[] = {"Labis", "na", "naiinip", "Nayayamot", "sa", "bawa't", "saglit"};
// modify the delay here --
int wordDelays[] = {500, 400, 1400, 1400, 300, 600, 1000};
void setup() {
Serial.begin(115200);
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
for (;;);
}
display.clearDisplay();
}
void loop() {
for (int i = 0; i < sizeof(words) / sizeof(words[0]); i++) {
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 20);
display.println(words[i]);
display.display();
delay(wordDelays[i]);
}
}
Take note that this code will loop.
Refer to the image below for the schematic diagram
OLED to ESP32 Pin connection:
| OLED | ESP32 |
|---|---|
| VCC | 3.3V OR 5V |
| GND | GND |
| SDA | GPIO 21 |
| SCL | GPIO 22 |
