Good morning everyone.
The idea is as follows: imagine that in a program there are 4 variables called variable1, variable2, variable3 and variable4. I want to do a FOR loop by running Serial.println on each of these 4 variables, but I don't want to write the name of each variable explicitly within the loop. I want to use the loop indexer (the i, for example) as a differentiator for the variable. Something like this:
void loop() {
variable1 = "a";
variable2 = "b";
variable3 = "c";
variable4 = "d";
for (int i = 1; i <= 4; i++) {
Serial.println(variable+i);
}
}
The parameter (variable + i) is just an idea. I know it doesn't work that way.
How to increase this?
Thanks
Gilberto