analog input as digital

HELLO!
I need to put a push button in an analog input because all the digital pin are busy doing their things.
I want to use pin A1, A2 and A3, I have an arduino nano board.

 byte   buttonPin2 = digitalRead(A3);
   if( buttonPin2==HIGH )  
   {
   
   r0 = 1; //bitRead() -> parameter 1 = binary sequence, parameter 2 = which bit to read, starting from the right most bit
   r1 = 0; //channel 7 = 111, 1 = 2nd bit 
   r2 = 0; // third bit
 Serial.print(r0);
  Serial.print(r1);
  Serial.print(r2);
  Serial.print(" ==== ");
  Serial.println(analogRead(0)); // after sending the binary sequence, the mux determines which channel to read from and sends it to this analog input
     
   delay (1000); // time to read the values
   }
   else 
   {
    Serial.println(digitalRead(A3));
   }

the problem is that even if I am not giving any voltage to the pin it print 001 === 542!!! where it should print 0.
where I am wronge?

Analogue input pins can be digital I/O pins, you just need to set the correct pinMode

yeah!!! I missed that!!! thanks a lot!

Serial.println(analogRead(0));

Why are you trying to read the RX serial pin as an analog?

Apparently arduino translates 0 to the analog pins...

Ps991:

Serial.println(analogRead(0));

Why are you trying to read the RX serial pin as an analog?

Analogue pin zero != digital pin zero

ok interisting...

I have a signal in INPUT A0 going out from mux, it is analog signal, not digital.

SoWhy are you trying to read the RX serial pin as an analog?
I wanted to read analog A0.
I miss the part where it is wrong, I though the Serial.print just sends to the serial monitor the result of the ADC convertion made using analogRead.

What I was asking before it was about A1, A2, A3 where I will put push button.
and after I put Serial.println(digitalRead(A3)); to see why it wasnt working, what kind of value was reading.

I miss the part where it is wrong

There is nothing wrong.
analogRead uses either 0 or A0 etc, as a separate numbering scheme for the analogue pins.

ok! Arduino it is tricking; but this is the second months I am working on it.
good good summer XD.
I have so many Idea I want to realize but step by step :slight_smile:
thanks you for the fast and good answer!

In future, it would help if you posted all your code - it saves time if we can see what else you've done.

I will!
:sunglasses: