Skip to content

Instantly share code, notes, and snippets.

@CountParadox
Created February 10, 2023 03:23
Show Gist options
  • Save CountParadox/c26ad880583dfbbf48bb2c4f77f1c5c9 to your computer and use it in GitHub Desktop.
Save CountParadox/c26ad880583dfbbf48bb2c4f77f1c5c9 to your computer and use it in GitHub Desktop.
const int button[8] = {0, 1, 2, 3, 4, 5, 6, 7};
const int LED[16] = {8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23};
int buttonState[8];
void setup() {
for (int i = 0; i < 8; i++) {
pinMode(button[i], INPUT_PULLUP);
}
for (int i = 0; i < 16; i++) {
pinMode(LED[i], OUTPUT);
}
Serial.begin(9600);
}
void loop() {
for (int i = 0; i < 8; i++) {
buttonState[i] = digitalRead(button[i]);
if (buttonState[i] == LOW) {
digitalWrite(LED[2 * i], !digitalRead(LED[2 * i]));
digitalWrite(LED[2 * i + 1], !digitalRead(LED[2 * i + 1]));
if (digitalRead(LED[2 * i]) == HIGH) {
Serial.println("M" + String(i) + "0");
}
else {
Serial.println("M" + String(i) + "1");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment