Skip to content

Instantly share code, notes, and snippets.

@willwade
Created June 1, 2020 14:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willwade/5b3fcf2f1d03edf7a771030ffbd4dc0e to your computer and use it in GitHub Desktop.
Save willwade/5b3fcf2f1d03edf7a771030ffbd4dc0e to your computer and use it in GitHub Desktop.
Arduino code for scrolling text on a OLED feathering
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_DC 11
#define OLED_CS 12
#define OLED_CLK 10
#define OLED_MOSI 9
#define OLED_RESET 13
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
char message[] = "Hello WOrrrrrllllllllllllllllllllllllllllldddd";
int x, minX;
void setup() {
display.begin(SSD1306_SWITCHCAPVCC);
display.setTextSize(2);
display.setTextColor(WHITE);
display.setTextWrap(false);
x = display.width();
minX = -12 * strlen(message); // 12 = 6 pixels/character * text size 2
}
void loop() {
display.clearDisplay();
display.setCursor(x, 20);
display.print(message);
display.display();
if(--x < minX) x = display.width();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment