Hello! Just started a project with some rgb leds.

Hello!
Just started a project with some rgb leds.
I cant find a simple example for a LED matrix, where i can simply define the leds i want to light up the same time. I want to make simple custom patterns. Is there a way to make these patterns with arrays?
Like i have a matrix: 10 rows, in each row 5 leds, connected in zigzag. And use an array like this:
0, 0, 0, 1, 0,
0, 0, 1, 0, 1,
0, 0, 0, 1, 0,
0, 1, 1, 1, 0,
1, 0, 1, 0, 0,
0, 1, 0, 1, 0,
0, 0, 0, 1, 1,
0, 1, 1, 1, 0,
1, 0, 1, 0, 0,
0, 1, 0, 1, 0,
And maybe change the colors individually?
I want to make a flat house, with lighting Windows:)
THanks for the help!
Máté

There’s an XYMatrix example in the library - https://github.com/FastLED/FastLED/blob/master/examples/XYMatrix/XYMatrix.ino

Oh cool! Many things running through my head… Random timers that select random rooms to light up. Rules that sometimes turn groups of lights (adjacent rooms on the same floor) on/off together. Very fun.

Is that HO scale?

There are some very cool effect in this

Thank you! I’m gonna check out these codes, the Kriegsman’s looks simplier at first look.
Sorry I’m a beginner in this theme, what HO means?

There will be two potmeters on the side of the boksz, so you can adjust it, and the lights will power up in random patterns. This is going to be a “controll table” for a video.
I’ll back if figured out the code or not!

@Mate_Varga HO refers to a modeling scale, commonly used with model railroading. I was wondering if that was an HO scale model building.

@marmil Oh, okay! No its not an HO scale. It’s just a random size, that fits to the printed image. Dont measure the scaling yet. I’m just got some help with the programming, and made a very simple starting code:

#include <FastLED.h>
#define LED_PIN 6
#define NUM_LEDS 50
#define BRIGHTNESS 64
#define LED_TYPE WS2812
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}
void loop(){
FastLED.show();
FastLED.delay(1000);

leds[0] = CRGB::Navy;
leds[1] = CRGB::Red;
leds[2] = CRGB::FairyLight;
leds[3] = CRGB::White;
…etc.
}
So I’m gonna use this to make the patterns with the right color.

Just build my first matrix, but wanted to say I wouldn’t code like that. It’s going to be insane for you to re-color having to change all of those individual values. My [still-quite-novice] instinct would be to at least have an array of color values (maybe just hue to keep it simple) and then cycle through your leds to set them. So you set the colors once (or programmatically) and then just assign them in a for loop.

hue = int[NUM_LEDS]
hue = { 0, 10, 20, … 255 } // fill with n hues; one per LED

for(int i = 0; i < NUM_LEDS; i++ {

leds[i] = CHSV(hue[i], 255, 255);

}

FastLED.show();

Does exactly what you’re doing, but now you’d just have to change comma separated numbers or use a function to re-populate the contents and the for loop that sets them still works just fine.