#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#include <FastLED.h>
#define RED_NUM_LEDS_PER_STRIP 161
#define GREEN_NUM_LEDS_PER_STRIP 105
#define BLUE_NUM_LEDS_PER_STRIP 63
#define SIGN_NUM_LEDS 121
#define BRIGHTNESS 128
#define PIN 6
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(11, 11, PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
NEO_GRB + NEO_KHZ800);
//GRB
const uint16_t colors[] = {
matrix.Color(0, 255, 0), matrix.Color(255, 0, 0), matrix.Color(0, 0, 255)
};
CRGB redLeds[RED_NUM_LEDS_PER_STRIP];
CRGB greenLeds[GREEN_NUM_LEDS_PER_STRIP];
CRGB blueLeds[BLUE_NUM_LEDS_PER_STRIP];
CRGB signleds[SIGN_NUM_LEDS];
void setup() {
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(200);
matrix.setTextColor(colors[0]);
FastLED.addLeds<WS2811, 9>(redLeds, RED_NUM_LEDS_PER_STRIP);
FastLED.addLeds<WS2811, 8>(greenLeds, GREEN_NUM_LEDS_PER_STRIP);
FastLED.addLeds<WS2811, 7>(blueLeds, BLUE_NUM_LEDS_PER_STRIP);
FastLED.addLeds<WS2811, 6>(signleds, SIGN_NUM_LEDS);
FastLED.setBrightness( BRIGHTNESS );
}
int x = matrix.width();
int pass = 0;
void sign_text() {
matrix.fillScreen(0);
matrix.setCursor(x, 0);
matrix.print(F("Merry christmas"));
if (--x < -135) {
x = matrix.width();
//if(++pass >= 3) pass = 0;
//matrix.setTextColor(colors[pass]);
}
matrix.show();
delay(80);
}
void led_show_1() {
for (int i = 0; i < RED_NUM_LEDS_PER_STRIP; i++) {
redLeds[i] = CRGB::Red;
FastLED.show();
delay(30);
}
for (int i = 0; i < GREEN_NUM_LEDS_PER_STRIP; i++) {
greenLeds[i] = CRGB::Green;
FastLED.show();
delay(30);
}
for (int i = 0; i < BLUE_NUM_LEDS_PER_STRIP; i++) {
blueLeds[i] = CRGB::Blue;
FastLED.show();
delay(30);
}
delay(3000);
for (int i = BLUE_NUM_LEDS_PER_STRIP - 1; i >= 0; i--) {
blueLeds[i] = CRGB::Blue;
FastLED.show();
blueLeds[i] = CRGB::Black;
delay(30);
}
for (int i = GREEN_NUM_LEDS_PER_STRIP - 1; i >= 0; i--) {
greenLeds[i] = CRGB::Green;
FastLED.show();
greenLeds[i] = CRGB::Black;
delay(30);
}
for (int i = RED_NUM_LEDS_PER_STRIP - 1; i >= 0; i--) {
redLeds[i] = CRGB::Red;
FastLED.show();
redLeds[i] = CRGB::Black;
delay(30);
}
}
void led_show_2() {
for (int i = 0; i < 2; i++) {
fill_solid( redLeds, RED_NUM_LEDS_PER_STRIP, CRGB(64, 0, 0));
fill_solid( greenLeds, GREEN_NUM_LEDS_PER_STRIP, CRGB(0, 64, 0));
fill_solid( blueLeds, BLUE_NUM_LEDS_PER_STRIP, CRGB(0, 0, 64));
FastLED.show();
delay(1500);
fill_solid( redLeds, RED_NUM_LEDS_PER_STRIP, CRGB(0, 0, 0));
fill_solid( greenLeds, GREEN_NUM_LEDS_PER_STRIP, CRGB(0, 0, 0));
fill_solid( blueLeds, BLUE_NUM_LEDS_PER_STRIP, CRGB(0, 0, 0));
FastLED.show();
delay(1500);
}
}
void loop() {
sign_text();
led_show_2();
}
Now sign_text and led show_2 run at the same time, with the letters in the sign_text moves ahead after led_show_2 have run two times.
Stuck in space....