Last active
November 8, 2022 10:12
-
-
Save barwis/77f32007e25ea4f51bbca9d7bc0fe8e2 to your computer and use it in GitHub Desktop.
Adafruit_SSD1306 128x32 OLED display on custom pins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Adafruit_SSD1306.h> | |
#include <Adafruit_GFX.h> | |
#include <pins_arduino.h> | |
#define SCREEN_WIDTH 128 // OLED display width, in pixels | |
#define SCREEN_HEIGHT 32 // OLED display height, in pixels | |
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) | |
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32 | |
#define OLED_SDA D6 | |
#define OLED_SCL D7 | |
Adafruit_SSD1306 display(128, 32, &Wire, OLED_RESET); | |
void setup() { | |
Wire.begin(OLED_SDA, OLED_SCL); // pass SDA and SCL pins here | |
// 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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment