From bf6d7b9635d370d07737524a8da9719ef8ab696d Mon Sep 17 00:00:00 2001 From: phga Date: Wed, 12 Jul 2023 14:02:55 +0200 Subject: [PATCH] fix: Reversed digitalRead to activate button press on DOWN --- src/main.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 6937984..743f635 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,7 +43,7 @@ void startupAnimation(); void resetPlayer(); void setup() { - // Serial.begin(9600); + Serial.begin(9600); // init pins for (int i = 3; i <= LMAX; ++i) { @@ -94,10 +94,10 @@ void loop() { // Setzt Status des Playerbuttons void anticheat(int l) { - if (digitalRead(p1.id) && l != LMAX) { + if (digitalRead(p1.id) == 0 && l != LMAX) { p1.pressed = 1; } - if (digitalRead(p2.id) && l != LMIN) { + if (digitalRead(p2.id) == 0 && l != LMIN) { p2.pressed = 1; } } @@ -149,6 +149,11 @@ void ledActive(int l, dir d) { // ret 1 wenn in zeit gedrückt, 0 sonst int pressLoop(player *p) { // Falls gecheated wurde, aussetzen + Serial.print("\nPressed: ("); + Serial.print(p->id); + Serial.print(", "); + Serial.print(p->pressed); + Serial.print(")"); if (p->pressed) { delay(speed); return 0; @@ -156,7 +161,7 @@ int pressLoop(player *p) { // Abfrageloop for (int i = 0; i < speed; ++i) { - if (digitalRead(p->id)) { + if (digitalRead(p->id) == 0) { return 1; } delay(1);