for (int i = 0; i < 8; i++) {
r = analogRead(A0 + i);
}
But for multiple r you need an array.
Variable names are no strings, so you either need r0… r7 declared sepeartely (making the loop a bit clumsy, since you’d need to use switch(i) case 0: or if(i == 0) to select the correct one, or int r[8] and just use an array.
@tomkut, A0-A7 are represented by values 10-17. You could create a array of pins and cycle though that:
int analogPins[] = {A0, A1, A2, A3, A4, A5, A6, A7};
for (int n=0; n < a ; n++) { // switching input terminal loop (0 to a-1, a < 8)
r[n]=analogRead(analogPins[n]); //measure the terminals (0 to a-1)
}
His makes the code more readable and keeps the pin abstraction