Skip to content

Instantly share code, notes, and snippets.

@smching
Created July 12, 2016 10:16
Show Gist options
  • Save smching/7c7678682a58dd711dea53f7cbf22175 to your computer and use it in GitHub Desktop.
Save smching/7c7678682a58dd711dea53f7cbf22175 to your computer and use it in GitHub Desktop.
Three buttons on one analog pin
/*
Arduino AD0
|
VCC---2K2---470---1k---
| | |
Up Down Select
(SW1) (SW2) (SW3)
| | |
Gnd--------------------
*/
void setup() {
Serial.begin(9600);
}
void loop() {
int adc_key_in = analogRead(0); // read the value from analog 0
//value read: 0(SW1),180(SW2), 410(SW3), 1023(OPEN)
Serial.println(adc_key_in);
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment