/**********************************
*Project : CoEIS Symposium – IoT contest
*Institution : DeVry University
*Example : OLED Display
*Program Purpose: Demonstrating OLED Display
*Date created : 2024.06.11
**********************************/
// Include libraries needed for the OLED1306 Display. Make sure these libraries are included
// in Library Manager Tab Make sure you use the correct spelling
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define redLED 13 // creates a macro, which associates reLED with value 13
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET 4
#define SCREEN_ADDRESS 0x3C
#define studentName "T. Tzvetkov"
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(redLED, OUTPUT); //configures a digital pin as an OUtPUT
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;);
}
display.display();
delay(2000);
display.clearDisplay();
display.setTextSize(1.8);
display.setTextColor(SSD1306_WHITE);//The library has multiple color definitions. If only one color is used that is the text color. Background is transparent
display.setCursor(0, 0);
display.println(studentName);
display.setCursor(0, 15);
display.println("DeVry");
display.setCursor(0, 30);
display.println("Competition " );
}
void loop() {
digitalWrite(redLED, HIGH); //Writes a value to the digital output
display.setTextColor(WHITE, BLACK); //Use explicit background when writing over text.
display.setCursor(0, 45);
display.println("Red LED ON ");
display.display();
delay(1000);
digitalWrite(redLED, LOW);
display.setCursor(0, 45);
display.println("Red LED ");
display.setTextColor(WHITE, BLACK);
display.setCursor(0, 45);
display.println("Red LED OFF ");
display.display();
delay(1000); // this speeds up the simulation
}