Hello I am having problems with the coding in both matrix examples.
I made my own 20 x 10 LED board for a final project. Its made from ws2812b LEDs that zig-zag across the board. I am using an Arduino Uno and powering the LED's and Arduino separately. All hardware is working because I was able to run another FastLED (non-Matrix) code with no problem. But I just had to modify 3 parameters on the code to work and I basically followed the steps on a youtube tutorial that showed what 3 numbers to change.
I am having problems trying to figure out what to edit in the code examples. I just need to get either NeoMatrix or SmartMatrix to work. I'm just trying to scroll "Statics Is Fun" across my home made panel in red.
I can't even get the example to run, that's what I have been trying to do initially. Here's the SmartMatrix code that I did. But this code only shows the bottom 30 pixles blinking. Obviously I'm doing something wrong. With NeoMatrix I can't get anything to light up.
Thanks in advance for the help.
#include <SmartMatrix.h>
#include <FastLED.h>
#define kMatrixWidth 20
#define kMatrixHeight 10
const bool kMatrixSerpentineLayout = false;
#define NUM_LEDS (kMatrixWidth * kMatrixHeight)
CRGB leds[kMatrixWidth * kMatrixHeight];
uint16_t XY( uint8_t x, uint8_t y)
{
uint16_t i;
if( kMatrixSerpentineLayout == false) {
i = (y * kMatrixWidth) + x;
}
if( kMatrixSerpentineLayout == true) {
if( y & 0x01) {
// Odd rows run backwards
uint8_t reverseX = (kMatrixWidth - 1) - x;
i = (y * kMatrixWidth) + reverseX;
} else {
// Even rows run forwards
i = (y * kMatrixWidth) + x;
}
}
return i;
}
// The 32bit version of our coordinates
static uint16_t x;
static uint16_t y;
static uint16_t z;
// We're using the x/y dimensions to map to the x/y pixels on the matrix. We'll
// use the z-axis for "time". speed determines how fast time moves forward. Try
// 1 for a very slow moving effect, or 60 for something that ends up looking like
// water.
// uint16_t speed = 1; // almost looks like a painting, moves very slowly
uint16_t speed = 20; // a nice starting speed, mixes well with a scale of 100
// uint16_t speed = 33;
// uint16_t speed = 100; // wicked fast!
// Scale determines how far apart the pixels in our noise matrix are. Try
// changing these values around to see how it affects the motion of the display. The
// higher the value of scale, the more "zoomed out" the noise iwll be. A value
// of 1 will be so zoomed in, you'll mostly see solid colors.
// uint16_t scale = 1; // mostly just solid colors
// uint16_t scale = 4011; // very zoomed out and shimmery
uint16_t scale = 31;
// This is the array that we keep our computed noise values in
uint8_t noise[kMatrixWidth][kMatrixHeight];
void setup() {
// uncomment the following lines if you want to see FPS count information
// Serial.begin(38400);
// Serial.println("resetting!");
delay(3000);
LEDS.addLeds<SMART_MATRIX>(leds,NUM_LEDS);
LEDS.setBrightness(96);
// Initialize our coordinates to some random values
x = random16();
y = random16();
z = random16();
// Show off smart matrix scrolling text
pSmartMatrix->setScrollMode(wrapForward);
pSmartMatrix->setScrollColor({0xff, 0xff, 0xff});
pSmartMatrix->setScrollSpeed(15);
pSmartMatrix->setScrollFont(font6x10);
pSmartMatrix->scrollText("Smart Matrix & FastLED", -1);
pSmartMatrix->setScrollOffsetFromEdge(10);
}
// Fill the x/y array of 8-bit noise values using the inoise8 function.
void fillnoise8() {
for(int i = 0; i < kMatrixWidth; i++) {
int ioffset = scale * i;
for(int j = 0; j < kMatrixHeight; j++) {
int joffset = scale * j;
noise*[j] = inoise8(x + ioffset,y + joffset,z);*
- }*
- }*
- z += speed;*
}
void loop() { - static uint8_t circlex = 0;*
- static uint8_t circley = 0;*
- static uint8_t ihue=0;*
- fillnoise8();*
- for(int i = 0; i < kMatrixWidth; i++) {*
- for(int j = 0; j < kMatrixHeight; j++) {*
- // We use the value at the (i,j) coordinate in the noise*
- // array for our brightness, and the flipped value from (j,i)*
- // for our pixel's hue.*
leds[XY(i,j)] = CHSV(noise[j],255,noise*[j]);*
* // You can also explore other ways to constrain the hue used, like below*
// leds[XY(i,j)] = CHSV(ihue + (noise[j]>>2),255,noise*[j]);*
* }*
* }*
* ihue+=1;*
* // N.B. this requires SmartMatrix modified w/triple buffering support*
* pSmartMatrix->fillCircle(circlex % 32,circley % 32,6,CRGB(CHSV(ihue+128,255,255)));*
* circlex += random16(2);*
* circley += random16(2);*
* LEDS.show();*
* // delay(10);*
}