// Button Bounce counter
//
// Red button has bouncing simulation enabled,
// Blue button has bouncing simulation disabled.
#define SWITCH_PIN1 13
#define SWITCH_PIN2 12
#define SWITCH_PIN3 11
#define SWITCH_PIN4 10
#define LED1 9 // LED 1
#define LED2 8 // LED 2
#define LED3 7 // LED 3
#define LED4 6 // LED 4
#define LED5 5 // LED 5
#define LED6 4 // LED 6
#define LED7 3 // LED 7
#define LED8 1 // LED 8
#define LED9 2 // LED 9
#define LED10 A5 // LED 10
#define LED11 A4 // LED 11
#define LED12 A0 // LED 12
#define LED13 A1 // LED 13
#define LED14 A2 // LED 14
#define LED15 A3 // LED 15
#define LED16 0 // LED 16
void setup() {
Serial.begin(115200);
pinMode(SWITCH_PIN1, INPUT_PULLUP);
pinMode(SWITCH_PIN2, INPUT_PULLUP);
pinMode(SWITCH_PIN3, INPUT_PULLUP);
pinMode(SWITCH_PIN4, INPUT_PULLUP);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(LED5, OUTPUT);
pinMode(LED6, OUTPUT);
pinMode(LED7, OUTPUT);
pinMode(LED8, OUTPUT);
pinMode(LED9, OUTPUT);
pinMode(LED10, OUTPUT);
pinMode(LED11, OUTPUT);
pinMode(LED12, OUTPUT);
pinMode(LED13, OUTPUT);
pinMode(LED14, OUTPUT);
pinMode(LED15, OUTPUT);
pinMode(LED16, OUTPUT);
}
int lastState = HIGH;
void loop() {
int value1 = digitalRead((SWITCH_PIN1));
int value2 = digitalRead((SWITCH_PIN2));
int value3 = digitalRead((SWITCH_PIN3));
int value4 = digitalRead((SWITCH_PIN4));
// 00
if (value1 == HIGH && value2 == HIGH && value3 == HIGH && value4 == HIGH) {
digitalWrite(LED1, HIGH);
digitalWrite(LED2, HIGH);
digitalWrite(LED3, HIGH);
digitalWrite(LED4, LOW);
digitalWrite(LED5, HIGH);
digitalWrite(LED6, HIGH);
digitalWrite(LED7, HIGH);
digitalWrite(LED8, HIGH);
digitalWrite(LED9, HIGH);
digitalWrite(LED10, HIGH);
digitalWrite(LED11, HIGH);
digitalWrite(LED12, LOW);
digitalWrite(LED13, HIGH);
digitalWrite(LED14, HIGH);
digitalWrite(LED15, HIGH);
digitalWrite(LED16, HIGH);
}
// 01
if (value1 == HIGH && value2 == HIGH && value3 == HIGH && value4 == LOW) {
digitalWrite(LED1, HIGH);
digitalWrite(LED2, HIGH);
digitalWrite(LED3, HIGH);
digitalWrite(LED4, LOW);
digitalWrite(LED5, HIGH);
digitalWrite(LED6, HIGH);
digitalWrite(LED7, HIGH);
digitalWrite(LED8, HIGH);
digitalWrite(LED9, LOW);
digitalWrite(LED10, LOW);
digitalWrite(LED11, HIGH);
digitalWrite(LED12, LOW);
digitalWrite(LED13, LOW);
digitalWrite(LED14, HIGH);
digitalWrite(LED15, LOW);
digitalWrite(LED16, HIGH);
}
// 02
if (value1 == HIGH && value2 == HIGH && value3 == LOW && value4 == HIGH) {
digitalWrite(LED1, HIGH);
digitalWrite(LED2, HIGH);
digitalWrite(LED3, HIGH);
digitalWrite(LED4, LOW);
digitalWrite(LED5, HIGH);
digitalWrite(LED6, HIGH);
digitalWrite(LED7, HIGH);
digitalWrite(LED8, HIGH);
digitalWrite(LED9, HIGH);
digitalWrite(LED10, LOW);
digitalWrite(LED11, HIGH);
digitalWrite(LED12, HIGH);
digitalWrite(LED13, HIGH);
digitalWrite(LED14, LOW);
digitalWrite(LED15, HIGH);
digitalWrite(LED16, HIGH);
}
// 03
if (value1 == HIGH && value2 == HIGH && value3 == LOW && value4 == LOW) {
digitalWrite(LED1, HIGH);
digitalWrite(LED2, HIGH);
digitalWrite(LED3, HIGH);
digitalWrite(LED4, LOW);
digitalWrite(LED5, HIGH);
digitalWrite(LED6, HIGH);
digitalWrite(LED7, HIGH);
digitalWrite(LED8, HIGH);
digitalWrite(LED9, HIGH);
digitalWrite(LED10, LOW);
digitalWrite(LED11, HIGH);
digitalWrite(LED12, HIGH);
digitalWrite(LED13, LOW);
digitalWrite(LED14, HIGH);
digitalWrite(LED15, HIGH);
digitalWrite(LED16, HIGH);
}
// 04
if (value1 == HIGH && value2 == LOW && value3 == HIGH && value4 == HIGH) {
digitalWrite(LED1, HIGH);
digitalWrite(LED2, HIGH);
digitalWrite(LED3, HIGH);
digitalWrite(LED4, LOW);
digitalWrite(LED5, HIGH);
digitalWrite(LED6, HIGH);
digitalWrite(LED7, HIGH);
digitalWrite(LED8, HIGH);
digitalWrite(LED9, LOW);
digitalWrite(LED10, HIGH);
digitalWrite(LED11, HIGH);
digitalWrite(LED12, HIGH);
digitalWrite(LED13, LOW);
digitalWrite(LED14, HIGH);
digitalWrite(LED15, LOW);
digitalWrite(LED16, HIGH);
}
}