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?
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.
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
thanks you for the fast and good answer!