Can you use an array to declare WidgetLED's?

So I know that I need to declare all the virtual LEDs I want to use, like this:

WidgetLED wet1(0);
WidgetLED dry1(1);
WidgetLED wet2(2);
WidgetLED dry2(3);
WidgetLED wet3(4);
WidgetLED dry3(5);
WidgetLED wet4(6);
WidgetLED dry4(7);

But I want to declare them like this:

WidgetLED wet[] = {1, 2, 3, 4};
WidgetLED dry[] = {1, 2, 3, 4};

When I try to turn them .on() or .off() i’m getting errors that I’m not sure how to fix…

All-in-all it looks like this:

int mSensor[] = {1, 2, 3, 4};
WidgetLED wet[] = {1, 2, 3, 4};
WidgetLED dry[] = {1, 2, 3, 4};;

for (int i = 0; i < 4; i++){
    int x = analogRead(i);
    mSensor[i] = map(x, 0, 4095, 0, 100);
    if (mSensor[i] > 50)
    {
        wet[i].on();
        dry[i].off();
    }
    else
    {
        wet[i].off();
        dry[i].on();
        pumpOn();
    }
}

But here I run into the problem that wet[i].on() was not declared in this scope… my brain is hurting trying to figure this out.

Hmm… now that I’m typing it out I see that using “WidgetLED wet[] = {1, 2, 3, 4};” creates the 4 virtual LEDs, but doesn’t assign them to a virtual pin… or it doesn’t create them at all… or ugh I don’t know.

Am I making any sense? I could use some pointers…

pointers? Yes, you needs those with arrays :wink:

But I think the WidgetLed is just a simple int when you create that object, see here:

public:
	WidgetLED(uint8_t pin) : mPin(pin) {}

Which basically states that what you want can’t be done with the current WidgetLed, but maybe @vshymanskyy has a better answer.