Multiple Neopixel animations

Hi all,

need some help running 2 neopixel animations at the same time. Millis is not something i’m familiar with using and i’m struggling to implement it. If anyone could help writing this into my code it’d be greatly appreciated. There a lot more to do on the project but i just need help getting off the ground. Code is attached.

Cheers

//


#include "FastLED.h"                                                                                            // Include Neopixel library

#define SPOT_1      12                                                                                           // Defines pinouts for Neopixel rings
#define SPOT_2      9
#define SPOT_3      11

#define NUM_STRIPS 2
#define NUM_LEDS    16                                                                                          // Number of neopixels per ring.   
#define LED_TYPE    NEOPIXEL                                                                                    // Defines use of neopixel chipset

CRGB spot1[NUM_LEDS], spot2[NUM_LEDS];                                                                         // Creates neopixel arrays

int HE1 = 18;                                                                                                    // Sets Hall Effect Sensor pins
int HE2 = 21;


int HE1State = 0;                                                                                               // Sets initial sensor states to LOW
int HE2State = 0;





void setup() {
  delay(100);
  Serial.begin(9600);

  FastLED.addLeds<LED_TYPE, SPOT_1>(spot1, NUM_LEDS);                                                           // Links all Neopixel rings to FastLED library.
  FastLED.addLeds<LED_TYPE, SPOT_2>(spot2, NUM_LEDS);


  pinMode(HE1, INPUT);
  pinMode(HE2, INPUT);

}

void loop() {
  Serial.println(F("Reading Signals "));

  HE1State = digitalRead(HE1);              // Look at reading all of the Hall Effect sensor inputs during the loop.
  HE2State = digitalRead(HE2);

  Serial.println(F("Signals read "));



  if (HE1State == LOW) {                    //If sensor is LOW flash Red
    flash();
    Serial.println(F("HE1 Flash "));
  }


  if (HE1State == HIGH) {                    //If sensor is HIGH solid Blue
    solid();                        // Delay affects speed of circling light. Higher delay = slower speed.
    Serial.println(F("HE1 Solid "));
  }


  if (HE2State == LOW) {                    //If sensor is LOW flash Red
    flash2();
    Serial.println(F("HE2 Flash  "));
  }

  if (HE2State == HIGH) {                    //If sensor is HIGH solid Blue
    solid2();
    Serial.println(F("HE2 Solid "));
  }
}

void flash() {
  Serial.println(F("Sensor 1 Low "));

  for (int i = 0; i < NUM_LEDS; i++) {
    spot1[i] = CRGB::Red;
    FastLED.show();
    delay(30);                           // Delay affects speed of circling light. Higher delay = slower speed.

    for (int i = 0; i < NUM_LEDS; i++)
      spot1[i].fadeToBlackBy(50);
    FastLED.show();
  }
}

void solid() {

  Serial.println(F("Sensor 1 High "));
  fill_solid( spot1, NUM_LEDS, CRGB::Blue);
  FastLED.show();
  delay(1000);                           // Delay affects speed of circling light. Higher delay = slower speed.


}


void flash2() {
  Serial.println(F("Sensor 2 Low "));

  for (int i = 0; i < NUM_LEDS; i++) {
    spot2[i] = CRGB::Red;
    FastLED.show();
    delay(30);                           // Delay affects speed of circling light. Higher delay = slower speed.

    for (int i = 0; i < NUM_LEDS; i++)
      spot2[i].fadeToBlackBy(50);
    FastLED.show();
  }
}

void solid2() {

  Serial.println(F("Sensor 2 High "));
  fill_solid( spot2, NUM_LEDS, CRGB::Blue);
  FastLED.show();
  delay(1000);                           // Delay affects speed of circling light. Higher delay = slower speed.


}

It is unclear if the two animations shall run on:

  1. two different LED strips
  2. on the same LED strip, with one on the left side, one on the right side
  3. on the same LED strip, mixing/blending/overlaying each other