Pages: [1]   Go Down
Author Topic: Analog In with digital inputs  (Read 558 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 52
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Thanks
John
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 617
Posts: 49463
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
int state = digitalRead(14);
or
Code:
int state = digitalRead(A0);
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 52
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks PaulS

John
Logged

Pages: [1]   Go Up
Jump to: