Last active
October 16, 2019 06:42
-
-
Save darrell24015/cbc121630daf82c3736bfb7132bfab3e to your computer and use it in GitHub Desktop.
Arduboy example of scrolling text on the screen
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
/* | |
* This code example shows how to scroll a line of text | |
* across the screen on an Arduboy. | |
* The OLED screen dimensions are 128 x 60 pixels (width x height) | |
*/ | |
#include <Arduboy2.h> | |
Arduboy2 arduboy; | |
// Create the variables needed | |
int x; | |
int y; | |
char* myGreeting = ("Hello world blah blah blah blah"); | |
void setup() { | |
arduboy.begin(); | |
arduboy.setFrameRate(30); | |
} | |
void loop() { | |
if (!(arduboy.nextFrame())) | |
return; | |
// Set the coordinates to start at the right edge of the screen | |
// and midway down on the Y-axis | |
x = 127; | |
y = 30; | |
// In the for() loop, use the screen width x 2 | |
// this allows the entire message to scroll across | |
// before starting over | |
for(int i = 0; i < 256; i++) { | |
arduboy.clear(); | |
arduboy.setCursor(x, y); | |
arduboy.print(myGreeting); | |
arduboy.display(); | |
delay(75); | |
x--; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment