Go Down

Topic: Analog In with digital inputs (Read 603 times) previous topic - next topic

J T

Can you use the analog inputs with digital input devices like pushbuttons?

Thanks
John

PaulS

Quote
Can you use the analog inputs with digital input devices like pushbuttons?

You can. But, you can also refer to the analog pins AS digital pins, using the names A0 through A5. These names correspond, on the Duemilanove/UNO to 14, 15, etc. They have different values on the Mega.

So, you can do
Code: [Select]
int state = digitalRead(14);
or
Code: [Select]
int state = digitalRead(A0);

J T


Go Up