Hi there,
I am using a 8x32 RGB matrix and wouldike to show a "starry sky" and a scrolling text alternating. Each of the programs runs well, but merging it does make the starry sky working only. Tried to put the two sections of code into FOR loops to separate them, but did not work as wel...Here is the code.
Can someone help me with that? I do not know where to search any more
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#define NUMpixeling 256
#define PIN 6
Adafruit_NeoPixel pixeling = Adafruit_NeoPixel(NUMpixeling, PIN, NEO_GRB + NEO_KHZ800);
// MATRIX DECLARATION:
// Parameter 1 = width of NeoPixel matrix
// Parameter 2 = height of matrix
// Parameter 3 = pin number (most are valid)
// Parameter 4 = matrix layout flags, add together as needed:
// NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT:
// Position of the FIRST LED in the matrix; pick two, e.g.
// NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
// NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal
// rows or in vertical columns, respectively; pick one or the other.
// NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed
// in the same order, or alternate lines reverse direction; pick one.
// See example below for these values in action.
// Parameter 5 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, PIN,
NEO_MATRIX_BOTTOM + NEO_MATRIX_RIGHT +
NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
NEO_GRB + NEO_KHZ800);
const uint16_t colors[] = {
matrix.Color(255, 255, 255), matrix.Color(0, 255, 0), matrix.Color(255, 255, 0), matrix.Color(0, 0, 255), matrix.Color(255, 0, 255), matrix.Color(0, 255, 255), matrix.Color(255, 255, 255)
};
int lrandNumber;
int i, u, p;
int TwinkleLEDs = 7; //How many LEDs shall be blink at a time
int LED[(7)], bright[7], fade[7]; //Must be same as TwinkeLEDs
void setup() {
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(1);
matrix.setTextColor(colors[0]);
randomSeed(analogRead(1)); //For random number
Serial.begin(57600);
pixeling.begin(); // This initializes the NeoPixel library
}
int x = matrix.width();
int pass = 0;
void loop() {
//Scrolling text startes here
matrix.fillScreen(0);
matrix.setCursor(x, 0);
matrix.print(F("Yes- all good"));
if (--x < -130) {
x = matrix.width();
}
matrix.show();
delay(30);
//End scrolling text
for (i = 0; i < (TwinkleLEDs - 1); i = i + 1) {
if ((u = bright[i]) <= 0)
{ lrandNumber = random(255); //Random number
LED[i] = lrandNumber; //LED
lrandNumber = random(75); //Random number
bright[i] = lrandNumber; //LED
lrandNumber = random(1, 3); //Random number
fade[i] = lrandNumber; //LED
delay(200);
}
else
{
// Fade out LED
(bright[i]) = (bright[i]) - (fade[i]);
//If brightness value <0, sets value to 0 avoiding negative numbers
if (bright[i] < 0) bright[i] = 0;
pixeling.setPixelColor(LED[i], pixeling.Color(bright[i], bright[i], bright[i]));
}
}
pixeling.show();
}