Go Down

Topic: Analog In with digital inputs (Read 622 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
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy