'LEDS' was not declared in this scope

Hello everyone
Im getting 'LEDS' was not declared in this scope in my void setup third line in there. Im attaching the code if anyone could help me out that would be awesome

#include <FastLED.h>

#define NUM_LEDS 8
#define NUM_STEPS 7
#define NUM_COLORS 4

const byte dataPin = 9;
const byte potPin = A0;

const long colors[NUM_COLORS] = { 0x00000000, 0x00ff0000, 0x0000ff00, 0x000000ff};
// 0 is Black or pixel off. 1 = red, 2 = green, 3 = blue
const byte rows[NUM_STEPS][NUM_LEDS] =
{
{1, 1, 0, 0, 0, 0, 0},
{0, 1, 1, 0, 0, 0, 0},
{0, 0, 1, 3, 0, 0, 0},
{0, 0, 0, 3, 3, 0, 0},
{0, 0, 0, 0, 3, 2, 0},
{0, 0, 0, 0, 0, 2, 2},
{0, 0, 0, 0, 0, 0, 2},
};

CRGB leds[NUM_LEDS];

void setup()
{
Serial.begin(115200);
Serial.println("starting\n");
LEDS.addLEDS<WS2812, dataPin, GRB>(LEDS, NUM_LEDS);
LEDS.setBrightness(60);
for (int n = 0; n < NUM_LEDS; n++)
{
leds[n] = CRGB::Yellow;
}
}

void loop()
{
static unsigned long timer = 0;
unsigned long interval = 20;
if (millis() - timer >= interval)
{
timer = millis();
// get simulated signal from receiver. 1000us - 2000us
// map servo signal to choose active row
int row = map(readPot(), 1000, 2000, 0, NUM_STEPS);

  for (byte n = 0; n < NUM_LEDS; n++)
  {
     leds[n] = colors[rows[row][n]];
  }
  FastLED.show();

}
}

int readPot()
{
int servoValue = analogRead(potPin);
servoValue = map(servoValue, 0, 1023, 1000, 2001);
//Serial.print("servo value ");
//Serial.println(servoValue);
return servoValue;
}

Notice that one is lower case letters and the other is upper case letters? Makes a difference!

I just cahnged all the lower case to upper to match and now its saying request member 'addLEDS' in 'LEDS', which is of non-class type 'CRGB [7]'

Check the documentation.

Where am I looking??

Here.

Start with an example that comes with the library. Save it under another name and start adding your own stuff.

look this example over
GitHub - FastLED/FastLED: The FastLED library for colored LED animation on Arduino. Please direct questions/requests for help to the FastLED Reddit community: http://fastled.io/r We'd like to use github "issues" just for tracking library bugs / enhancements.


#include <Arduino.h>
#include <FastLED.h>


#define DATA_PIN 3
#define CLOCK_PIN 13

#define NUM_LEDS 1
CRGB leds[NUM_LEDS];

void setup() {
    //Serial.begin(9600);
    //Serial.println("BLINK setup starting");

    delay(2000);

    FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);  // GRB ordering is assumed

    //Serial.println("BLINK setup complete");
}

void loop() { 
  //Serial.println("BLINK");
  
  // Turn the LED on, then pause
  leds[0] = CRGB::Red;
  FastLED.show();
  delay(500);
  
  // Now turn the LED off, then pause
  leds[0] = CRGB::Black;
  FastLED.show();
  delay(500);
}

Please read the pinned post re 'How to get the most from the forum'
Posting your code is good, but the way you posted it is wrong.

With all respect, every single reply the OP received was not particularly helpful! I’ve just had the exact same issue with code I haven’t touched for years, which suddenly broke when I needed to recompile. Rolling back FastLED library versions didn’t help and I was on the verge of trying to blame the new IDE

The issue is that OP and I have had, is that
LEDS.addLEDS
USED to work. For whatever reason, and I will not pretend to understand why, the solution is to change to
FastLED.addLEDS

I can 100% confirm that I started with an example way back when and, as was suggsted, added stuff to it. If OP has done the same but come across an older example, they will likely have experienced the same issue.

I know its The Internet and everyone who replied on this forum is probably somewhere approaching an SME.. but the people who are posting here asking for help, are not.. why bother replying with snark and non-answers..?

Your confidence not withstanding, I'm highly skeptical. LEDS is tpically an array of CRGB objects. Over the years that I've been using FastLED, that struct never had a member function called addLEDS().

FastLED on the other hand is an object of the CFastLED class that has always had a member function called addLEDS().

If you can dig back far enough in the GitHub versions to prove me wrong, I'll concede the point.

CRGB leds[NUM_LEDS];

uint8_t changeLEDS[NUM_LEDS];




void setup()

{

  delay(500);

  Serial.begin(9600);

  delay(500);

  if (ledType.equals("G4W"))

  {

    LEDS.addLeds<SK9822, LED_PIN, CLOCK_PIN, BGR>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);

  }

  else if (ledType.equals("G3W"))

  {

    LEDS.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);

  }

is live and running the lights on ~12,000 gaming machines in the UK.

File was last saved March ‘23, so that looks like most likely FastLED 3.5.0 - rolled back and the code above now compiles again.

For science, I’ve rolled forward and forward to find where it stopped working - I’ve done binary chop so it may have broken / fixed / broken and I won’t have seen that.

It starts to break at 3.10.2 - I would GUESS its something in this innocuous line in the changelog!!

Internal stuff

FastLED is now way more strict in it's compiler settings. Warnings are treated as errors

Lots of fixes, some code required amnesty.


This means that a lot of the examples that are ‘around’ that have the (yes, admittedly, wrong - not arguing that!!) LEDS.addLEDS() within them will now be breaking.

Now.. as to which example I started with, and whether it even came from the FastLED repos or somewhere else in the great wilds of the internet… now that I can’t say!

EDIT: Additionally, I cannot possibly pretend to know enough as to dig into 3.10.2 to find out WHAT made it stop listening to LEDS.AddLEDS() , nor could I say whether it no longer working could be considered a bug (I very much doubt it) but, I’ll warrent there’ll be a few people like @jackedman scratching their heads!

Nice detective work, I stand corrected. Here's your culprit in the file FastLED.h:

#ifndef LEDS
/// Alias of the FastLED instance for legacy purposes
#define LEDS FastLED
#endif

Those lines were removed starting in Release 3.10.2. I don't know why.

So, (capital) "LEDS" makes sense as it's aliased to a CFastLED object. I think additional confusion is caused by many people using (lower case) "leds" as the name of their CRGB array. As I pointed out, that struct has never had a addLEDS() member function.

So, you could add the above lines to the top of your code and would need to change nothing else.

I entered an issue on GitHub:
https://github.com/FastLED/FastLED/issues/2166

They've restored the aliases in the latest commit:
https://github.com/FastLED/FastLED/commit/10c42f22929121652b7e7921d10d12d94f23a5d0