Assign a led widget to a variable

Hello Blynkers!

Maybe this is an easy question, but I did not succeed with my tests. What I’m trying to do is:
Perform a for () for 10 iterations, however for each iteration, it will be a new led widget. So I was wanting to assign a led to a variable, something like int X = led_device_a (V20);. I also tried with string, but to no avail. The intention is in the for () function to call the variable x, assigned from a led, to something like x.on (); or ();

Can you post the code you have tried? OR even just the for loop?

Take a look at this example:



Solved! Thanks Pete. Just one look to the example, and changed my for() starting at 20, so, the int i controls VPin 20 to 24.

1 Like

The example provided by @Gunner is in the setup .
if you want to use outside the setup, you need a timer,
otherwise you will disconnects because ‘for next’ is a blocking loop.


1 Like