Greetings!  This is my first post,

Greetings! This is my first post, and I feel like such a n00b. I’m pretty good with computers and the like, but very VERY new with C programming.

I have a matrix of LED lights arranged in a 10x10 grid. I’ve been able to do some basic coloring of the lights as a whole, and understand how to program each light individually (by choosing 0-99). What I can’t seem to figure out is how to make groupings of lights (is this what is called an array?), so that I can affect several lights at once with a single line of code. Right now, even affecting all 100 lights at once, I can still tell that it’s going one by one down the rows. Can I blink all 100 at once without the “for(int all = 0; all < NUM_LEDS; all++)” serial/sequence style?

For example, I would like to create a label called Row1 (or I could call it “banana” for all I care) for lights 0 through 9, a label called Row2 for lights 10 through 19, etc and so forth. However I’ve scoured the net for the past 2 days and can’t seem to figure it out. I’m making the assumption that there is an easy way to do this, but I’ve made incorrect assumptions before, and don’t know enough about C to know what I can and can’t do yet.

Can someone help me? If you would like to see my basic code I’m running now, you can follow this link:
https://drive.google.com/file/d/0B9OCnB_7Mk7IazV5dXQzaGNxQ0U/view?usp=sharing

One easy way is to make a few arrays with preset patterns then just copy them over to the led array when you want that pattern.

There are also some functions in the library that affect the whole string at once.

Welcome nOOb, have you heard of http://pastebin.com? Try using that to share code snippets, it makes it a ton easier to share.

In this case it looks like you can boil things down in your code to a switch case statement: http://arduino.cc/en/Reference/SwitchCase

void rainbowloop(){
switch(rainbow){
case 1: hue = 0; break;
case 2: hue = 32; break;
case 3: hue = 64; break;
case 4: hue = 96; break;
case 5: hue = 128 break;
}

for(int all = 0; all < NUM_LEDS; all++) {
leds[all] = CHSV( hue, 255, 255)
}
LEDS.show();
LEDS.delay(50);
if(rainbow++ > 5) { rainbow= 1; }
}

Thanks for the info Jon. I tried playing around with SwitchCase, but couldn’t quite get it to do what I wanted right now. But I’ll definitely keep that info as it seems like it will be handy in the future. A friend gave me an idea to modify what I already had to allow me to control each row. Here’s the code for that:

http://pastebin.com/HuHdzF23

and here is what it looks like:

https://drive.google.com/file/d/0B9OCnB_7Mk7IT1NkSElZN0xTUzQ/view?usp=sharing

I’m glad this worked, but it’s still not exactly what I’m looking for. I would also like to be able to do columns, however it’s not as simple because those LEDs aren’t in sequence. I would like to be able to light up LEDs 0,19,20,39,40, etc. Here is my pixelmap for reference:

https://drive.google.com/file/d/0B9OCnB_7Mk7IWTBDSnhVbUthNGc/view?usp=sharing

Also, say I wanted to make the inner square of pixels 44,45,55,54 to be one solid color. How do I separate little “blobs” of pixels which I can call “blob1”, “blob2”, etc.

Is there another way to modify the Switch/Case command to allow this?

If you’ve arranged your 100 pixels into a 10 x 10 grid and want to address them by specifying (x, y) coordinates, take a look at this in FastLED’s examples directory:

https://github.com/FastLED/FastLED/blob/FastLED2.1/examples/XYMatrix/XYMatrix.ino

It sounds like you might want to define a new C++ Class called something like Rectangle, which would have data members called (for example) “top”, “bottom”, “left”, and “right”. Then you could make a method on that class called “fill” that took a color as an argument, for example.
Sort of like this (which I haven’t even tried compiling)…

class Rectangle {
public:
int top, bottom, left, right;

// constructor
Rectangle( int t, int b, int l, int r) {
  top = t; bottom = b; left = l; right = r;
}

void fill( CRGB color ) {
  for( int y = top; y <= bottom; y++) {
    for( int x = left; y <= right; x++) {
      leds[ XY( x,y) ] = color;
    }
  }
}

};

Then (assuming it actually worked!) you could use it like this:

Rectangle blob1( 4,5, 4,5); // from (4,4) to (5,5)
Rectangle blob2( 7,9, 2,4); // from (7,2) to (9,4)

blob1.fill( CRGB::Red );
blob2.fill( CRGB::Blue);

So the short version is that you probably want to define a C++ class for your ‘blob’ idea (e.g., like Rectangle, above), and then put methods on it that do what you want to do with it.

(This example also assumes that you have an array called ‘leds’, and that you’ve included the “XY” helper function from the XYMatrix example, and set it up for your matrix, etc. – Try starting from that example, perhaps?)

Sorry for being so slow with the reply, life has been busy, haven’t had much time for programming. Thank you so much everyone! I have been taking time to learn and figure some things out. Still couldn’t figure out how to do exactly what I wanted, but I later found Mark’s Noise code, and that actually is what I was trying to figure out (program frame by frame – so stupid and pointless now that I found the noise code!)

I also really like the XY mapping, and just starting to figure out switch-case for a new project I’m creating as a Christmas present. But that’s a whole other post I’m sure you’ll come across soon.

Thanks again!

I am also sure I will probably use the class defining in future projects I have floating around in my brain.