Categories
Uncategorized

LittleBits/Matrix Color Rotator Code for Twilio Signal HackPack

I made my twitter handle scroll across the screen, changing colors as it goes – pretty simple effect, but here’s the Arduino code:

#include <Adafruit_NeoPixel.h>
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>

#define PIN 1

Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(8, 8, PIN,
NEO_MATRIX_TOP + NEO_MATRIX_RIGHT +
NEO_MATRIX_COLUMNS + NEO_MATRIX_PROGRESSIVE,
NEO_GRB + NEO_KHZ800);

void setup() {
// put your setup code here, to run once:
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(30);
matrix.setTextColor( matrix.Color(0, 0, 255) );

}

int x = matrix.width();

int colorRotator = 0;

void loop() {
// put your main code here, to run repeatedly:
matrix.fillScreen(0);
matrix.setCursor(x, 0);
matrix.print(F("@jefflinwood"));
if(--x < -70) {
x = matrix.width();
colorRotator++;
}
if (colorRotator > 3) {
colorRotator = 0;
}
if (colorRotator % 3 == 0) {
matrix.setTextColor( matrix.Color(0, 0, 255) );
} else if (colorRotator % 3 == 1) {
matrix.setTextColor( matrix.Color(0, 255, 0) );
} else {
matrix.setTextColor( matrix.Color(255, 0, 0) );
}
matrix.show();
delay(100);
}

Leave a Reply

Your email address will not be published. Required fields are marked *