in the game controller you don't put end = true; (better than HIGH for a boolean) when you have won or pressed too fast.
if (bericht.ontvangerUID == 1 && bericht.alleCons == 0) //Gaat het bericht naar een speciafieke con?
{
if (bericht.command == 'F') //If the incoming message is 'F' it means you have pressed too fast.
{
tone(buzz, 1000); //normaal laten trillen
digitalWrite(vibr, HIGH);
delay(1000);
noTone(buzz);
digitalWrite(vibr, LOW);
}
else if (bericht.command == 'T')//If the incoming message is 'T' it means you are the winner.
{
tone(buzz, 1000);
digitalWrite(vibr, HIGH);
}
}
instead of
isGedrukt = LOW; //The next game the button will be able to be pressed again. Its a reset.
you should wait for the button to be realeased
while(digitalRead(knop) == LOW); // active wait
isGedrukt = false;
On the hub side, how is your button wired? -> I see it's an INPUT_PULLUP but you check if it's pressed like this:
if (digitalRead(knopM) == HIGH) //If the button is pressed.
why isn't that LOW since you are in INPUT_PULLUP mode?
Always use unsigned long for your millis() related variables like tijdTimer or huidigeTijd or you might get in trouble if you keep the game running for 25 days ![]()
I think your loop is more complex than it should be, in my view you should always listen to messages and write a small state machine to decide what to do with the message or button press