How to call the Ax states in a loop?

loopingz:
I have the folllowing piece of code:

 digitalWrite(A1, HIGH); //for debug info and learning process

digitalWrite(A2, LOW); //for debug info and learning process
 digitalWrite(A3, LOW); //for debug info and learning process
 for (int i=0 ; i<3 ; i++ ) {
   lcd.setCursor ((4+3*i),2);

lcd.print(digitalRead((15+i)));
   //lcd.print(HIGH);
   
 }




I would need to print the state of A1 then A2 then A3. I try to call them as input 15 16 17 (I believe it works that way).
I read 1 1 1 instead of 1 0 0
I tried lcd.print(HIGH); returns 1 and lcd.print(LOW); returns 0 as expected.


I obviously miss something here.
Any clue?

Another thing to be aware of: (A1 == 15 && A2 == 16 && A3 == 17) == TRUE only for UNOs and clones (and probably leonardo, any other Arduino that only has 13 digital I/Os, or 328 based Arduino). The Mega and DUE (for example) both have physical locations for 15, 16, and 17 (as well as 14 (would be A0 on the UNO) and 18 through 53). Might want to set up an array like: byte digitalInputs[] = {A1, A2, A3}; and then cycle through the array with something like for (i=0...etc) {digitalRead(digitalInputs[ i ])}. This way the IDE takes care of assigning the correct hardware pin based on your target board.

Or... keep track of what state you want the pin levels to be. If your script is the one setting the states then it should already know.