Skip to content

Instantly share code, notes, and snippets.

@bburky
Created August 11, 2022 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bburky/6ae38b426b39a7f0be03a87006f6ef7e to your computer and use it in GitHub Desktop.
Save bburky/6ae38b426b39a7f0be03a87006f6ef7e to your computer and use it in GitHub Desktop.
"Hello my name is ..." esp8266 (ESP-01) nametag on 128x64 monochrome 0.96" SSD1306 OLED
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
// The pins for I2C are defined by the Wire-library.
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup() {
Wire.begin(2, 0);
Serial.begin(9600);
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;); // Don't proceed, loop forever
}
// Show initial display buffer contents on the screen --
// the library initializes this with an Adafruit splash screen.
display.display();
display.clearDisplay();
display.setRotation(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(36, 0);
display.setTextSize(2);
display.println(F("HELLO"));
display.setCursor(4, 14);
display.setTextSize(2);
display.println(F("my name is"));
display.fillRect(0, 32, 128, 64, SSD1306_WHITE);
display.setCursor(4, 34);
display.setTextSize(4);
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
display.println(F("Blake"));
display.display();
ESP.deepSleep(0);
}
void loop() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment