Hey! I'm really new to FastLED and Arduino.

Hey! I’m really new to FastLED and Arduino. I’m starting to understand the code but I’ve reached a wall. I have a 16x16 array of WS2811 LED’s and am trying to use the XY Matrix to create a circle the propagates from the center of the array outward then fades to black. Any tips?

Welcome! One possible way: describe x by a sinus function and y by a cosinus function. (use FastLEDs sin8 and cos8) Scale the results for circles with different diameters. For fading just don’t delete the leds-array but scale it down (scale8). Use at the beginning the serial monitor to observe the results the functions give you. Helpful?

Because I’m a newbie and and things like sinus and cosinus functions are beyond me at this point… I create arrays of the leds I want displayed and then call them up in the order I need. I usually start with a numbered chart of my LED grid to make it easier.

So, for your example, I would light up the middle four leds. Then turn them off and light the ring around them. Then turn those off and light the next ones, etc.

If you HSV you can even change the color and/or brightness of the ring as it expands.

@allanGEE - Counting pixels is for chumps, so why not let high school math do the work for you. There’s lots of examples out there using sin8, beatsin8, so all you need to do is look around. It’s not that hard to pick up if you start out with something simple, such as moving a single LED back and forth with a sine function.

As I always tell people, start with something simple and build upon it.

Aaron LIddiment’s library has a function for drawing circles: https://github.com/AaronLiddiment/RGBLEDS

Using it, declare a global or static variable for the radius, then call:

DrawCircle(x, y, r, color);

Then increment the radius until you hit your max. If you want to slow it down, instead of using a large delay, you can use:

EVERY_N_MILLIS(30) { r++ };

@Andrew_Tuline If I was doing straight lines at the moment, I’d play more with the math (or manipulate other people’s math). But the serpentine layout of my grid is throwing me off. For example, to have an LED ‘move’ from 0 straight up the grid, I can’t just ++ the same number over and over… I have to account for the zigzag. Much more fun to have clunky code at this point and be able to watch the pretty lights! I’ll get better at it eventually, but I’d rather be a chump with lights, than a poor mathematician with dark LEDs! :slight_smile:

Here’s a good serpentine demo at:

I’m already playing with that one.

I started reading the code and got to this part…

Suppose you have an 8 x 5 matrix of 40 LEDs. Normally, you’d
// delcare your leds array like this:
// CRGB leds[40];
// But instead of that, declare an LED buffer with one extra pixel in
// it, “leds_plus_safety_pixel”. Then declare “leds” as a pointer to
// that array, but starting with the 2nd element (id=1) of that array:
// CRGB leds_with_safety_pixel[41];
// const CRGB* leds( leds_plus_safety_pixel + 1);
// Then you use the “leds” array as you normally would.
// Now “leds[0…N]” are aliases for “leds_plus_safety_pixel[1…(N+1)]”,
// AND leds[-1] is now a legitimate and safe alias for leds_plus_safety_pixel[0].
// leds_plus_safety_pixel[0] aka leds[-1] is now your “safety pixel”.

That’s when my wife walked into the room and found me on the floor in the fetal position, drooling.

:slight_smile:

I’m still in the baby steps stage… but the steps are getting bigger. Not sure I’ll ever be able to run with it, but confident I’ll work my way up to a brisk walk.

Thanks for the link to the example! I love how helpful everyone is around here.