2

Using the FastLED library, I want to light up multiple lights at once.

Currently I am passing in just one light to the function.

spell( int LEDNumber )
{
  FastLED.clear();
  leds[LEDNumber] = CRGB (255,255,255); //white
  FastLED.show();
  time = 500;
  delay(t);
}

I would like to pass in more than just 1 light at a time.

Joshua Dance
  • 141
  • 1
  • 6

2 Answers2

2

You may create a struct with "x" elements, one for each LED:

struct ArrayOfBooleans {
   bool array[4];
};

ArrayOfBooleans myOutputArray;
myOutputArray.array[0] = true;
myOutputArray.array[1] = true;
myOutputArray.array[2] = false;
myOutputArray.array[3] = true;

lightEmUp(myOutputArray);

void lightEmUp(ArrayOfBooleans myOutputArray) {
   bool isFirstLightOn = myOutputArray.array[0];
   // etc
}

NoTE: If you run into Exception 9 issues (using this logic on another board), please check this answer to another post

tony gil
  • 378
  • 1
  • 7
  • 26
1

Easier than I thought. Found it while reading the docs. Imagine that. :)

To pass in multiple variables, just separate them with a comma.

Docs: https://www.arduino.cc/en/Reference/FunctionDeclaration

Relevant code:

int myMultiplyFunction(int x, int y){
  int result;
  result = x * y;
  return result;
}
Joshua Dance
  • 141
  • 1
  • 6