Hello As a beginner with Arduino libraries I need help regard creating an instance

Hello

As a beginner with Arduino libraries I need help regard creating an instance of FastLED. I was trying to create an object “myLED” but I did not succeed at the end.
Please take a look at my example:

#include “FastLED.h”

// How many leds in your strip?
#define NUM_LEDS 1

// For led chips like Neopixels, which have a data line, ground, and power, you just
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
#define DATA_PIN 3
#define CLOCK_PIN 13

// Define the array of leds
CRGB leds[NUM_LEDS];

void setup() {

  FastLED myLED = FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);

// I create myLED object

}

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

This is my first use of library, I would like to learn how to create an instance of
class FastLED. Is it ok to train myself around libraries with this library? If I look at stepper motor example in Arduino IDE the instantiate doesn’t look so difficult. Please tell me how to do it. Best Regards, Branko

FastLED is already an object - if you look at the existing examples for FastLED, you’ll see that they just use FastLED, they don’t need to assign anything like you’re doing up there. Because of the way FastLED manages state you shouldn’t instantiate your own version of the object.

That said - there is an advanced usage of the library where, as you call addLeds, you can get references to the internal led controller objects generated for each call to addLeds - see https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples#managing-your-own-output for some information on that. However, that’s some fairly advanced usage of FastLED.

Thank you Daniel, you answer is much appreciated.
I noticed at examples that they just use FastLED. As a beginner I imagined to myself that I can create an instance from any library.
Generally I would like to learn how to use libraries, create new instances, object oriented programming …etc
I know this is topic for arduino forum.
Anyway I wil continue to work with FastLED, I saw the example on your link. I understand it, this is what I was looking for, here I really don’t need my own object, it’s really understandable.
For the exercise I tryed to modify the folowing example

#include “FastLED.h”

#define NUM_LEDS 80
#define NUM_STRIPS 4

CRGB myLed1[NUM_LEDS];
CRGB myLed2[NUM_LEDS];
CRGB myLed3[NUM_LEDS];
CRGB myLed4[NUM_LEDS];
uint8_t gBrightness = 128;

void setup() {
FastLED.addLeds<WS2812,1>(myLed1, NUM_LEDS);
FastLED.addLeds<WS2812,2>(myLed2, NUM_LEDS);
FastLED.addLeds<WS2812,10>(myLed3, NUM_LEDS);
FastLED.addLeds<WS2812,11>(myLed4, NUM_LEDS);
}

void loop() {
// draw led data for the first strand into leds
fill_solid(myLed1, NUM_LEDS, CRGB::Red);
FastLED[0].showLeds(gBrightness);

// draw led data for the second strand into leds
fill_solid(myLed2, NUM_LEDS, CRGB::Green);
FastLED[2].showLeds(gBrightness);

// draw led data for the third strand into leds
fill_solid(myLed3, NUM_LEDS, CRGB::Blue);
FastLED[3].showLeds(gBrightness);

// draw led data for the first strand into leds
fill_solid(myLed4, NUM_LEDS, CRGB::White);
FastLED[4].showLeds(gBrightness);
}

Is that correctly?
One more question, is it possible to use FastLED with ESP32 board?
The board has wifi/bluetooth connectivity, in the future I would like to make propeller display which shows the data from the internet (using FastLED).
Daniel, thank you again.

@Branko_Doljac The current FastLED library has support for ESP8266. Sam Guyer has made some updates to the library so that it will work with ESP32.

@marmil Thank you for the good news