Hello. I have a problem that one of the buttons(in this code mygt) wont start counting points. Where have i made mistake?
int myg = 7;
int mygt = 8;
int sk1 = 0;
int skai = 0;
int state = LOW;
int reading;
int previous = HIGH;
int statee = LOW;
int readingg;
int previous1 = HIGH;
long time = 0;
long debounce = 200;
long debounce1 = 200;
void setup() {
pinMode(myg, INPUT);
pinMode(mygt, INPUT);
Serial.begin(9600);
}
void loop() {
reading = digitalRead(myg);
readingg = digitalRead(mygt);
if (readingg == HIGH && previous1 == LOW && millis() - time > debounce) {
if (state == HIGH)
state = LOW;
else
state = HIGH;
}
if (reading == HIGH && previous == LOW && millis() - time > debounce) {
if (statee == HIGH)
statee = LOW;
else
statee = HIGH;
}
if (state == HIGH)
{
skai ++;
statee = LOW;
}
if (statee == HIGH)
{
sk1 ++;
state = LOW;
}
Serial.println("Team1");
Serial.println(skai);
Serial.println("Team2");
Serial.println(sk1);
previous = reading;
previous = readingg;
delay(1000);
}