Created
June 1, 2020 14:46
-
-
Save willwade/5b3fcf2f1d03edf7a771030ffbd4dc0e to your computer and use it in GitHub Desktop.
Arduino code for scrolling text on a OLED feathering
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 <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