
CD-PC Website Arduino Neopixel text example

Description:
Neopixel shield showing of scrolling tekst with different colors
Code works on a Arduino Uno v3
Code:#include
#include
#include
#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif
#define PIN 6
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(5, 8, PIN,
NEO_MATRIX_TOP + NEO_MATRIX_RIGHT +
NEO_MATRIX_COLUMNS + NEO_MATRIX_PROGRESSIVE,
NEO_GRB + NEO_KHZ800);
const uint16_t colors[] = { matrix.Color(164, 27, 57), matrix.Color(218, 230, 74), matrix.Color(127, 127, 127) };
char yourText[22] = "Gathering.Tweakers.net";
int pixelPerChar = 6;
int maxDisplacement;
void setup()
{
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(40);
matrix.setTextColor(colors[0]);
maxDisplacement = strlen(yourText) * pixelPerChar + matrix.width();
}
int x = matrix.width();
int pass = 0;
void loop()
{
matrix.fillScreen(0);
matrix.setCursor(x, 0);
matrix.print(yourText);
if(--x < -maxDisplacement)
{
x = matrix.width();
if(++pass >= sizeof (colors) / sizeof (uint16_t)) pass = 0;
matrix.setTextColor(colors[pass]);
}
matrix.show();
delay(100);
}
Result:
Status: Final.
Last page update: 29-05-2016