Custom LED Rave Mask Project - Near completion

Your leds are numbered like this:

And the line is displayed when these leds are on

int beat_line [] = {42, 43, 44, 45, 46, 47, 48, 49, 50, 51};

The heartbeat is when these leds are on:

int heartbeat [] = {42, 43, 44, 39, 26, 18, 5, 27, 46, 63, 56, 47, 36, 35, 34, 33}

If you want to display as if the HB peak was going from left to right, you'll have 2 problems:

  • The end line of the HB is not at the same level as the beginning line (36-33 is higher than 42-44)
  • When the rising edge reaches the left side of your array (after 44 is shifted to 42), the next step will make the beginning of the rising edge disappear, you'll only have a part of it displayed.

So maybe you should put the end line at the same level as the beginning line (i.e. 48-51 instead of 36-33).

int heartbeat [] = {42, 43, 44, 39, 26, 18, 5, 27, 46, 63, 56, 47, 48, 49, 50, 51}

For the animation, the simplest is to define other arrays to lit the leds according to the movement of the HB signal. Example, for one step to the left:

int heartbeatMinus1 [] = {42, 43, 40, 25, 19, 4, 26, 45, 62, 57, 46, 47, 48, 49, 50, 51}

And so on...

Then to run the animation:

void loop() {

FastLED.clear();
for(int i = 0; i < 16; i++) {
    leds[heartbeat[i]] = CRGB::Red;
    FastLED.show();
    delay(28);
  }

FastLED.clear();
for(int i = 0; i < 16; i++) {
    leds[heartbeatMinus1[i]] = CRGB::Red;
    FastLED.show();
    delay(28);
  }

FastLED.clear();
for(int i = 0; i < 16; i++) {
    leds[heartbeatMinus2[i]] = CRGB::Red;
    FastLED.show();
    delay(28);
  }

etc...
}

For a better looking code, you should define 2D arrays and do the animation with loops.