Combine Start of a variable name with index


I was wondering if I would be able to combine a start of a variable name with the number of an index so that I can get the data of the 'newly created' variable.

For example:

for ( i = 0; i < 5; i = i + 1){
    if ("Switch" + String(i) == true) {
          Serial.println("Variable is true")

I saw this topic where someone wanted to get similar results, but sadly it was in German and my German isn't the best in the world :sweat_smile: link

Variable names don't exist after compilation.

Use arrays.

The advice given was the same: use an array.

right, thanks! I'll try that than :wink:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.