BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Assign a led widget to a variable

#1

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 x.off ();

0 Likes

#2

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

0 Likes

#3

Take a look at this example:

Pete.

2 Likes

#4

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

#5

The example provided by @GunnerTechTools 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.
Alex

0 Likes

#6

Thanks!

1 Like