Hi All,
I’ve built a very basic robot for a party, and for periods of time I want it to appear as though it doesn’t move (I’ve called this ‘Stealth mode’ in my code to make it sound cool), before being activated by a remote control which brings it back to life (it doesn’t matter which button is pressed). If a button isn’t pressed, then eventually ‘Stealth Mode’ times-out and we return to the main loop. I’ve written a function for this ‘Stealth mode’ and it largely works as intended, but it’s sometimes registering button presses that haven’t been made and interrupting the ForLoop. Code for the function below:
void stealth () {
lightsoff();
delay (100);
Serial.println("Stealth Mode Started");
for (int d = 0; d < stealthpausetime; d++) {
Serial.println(d);
if (irrecv.decode(&results)) // have we received an IR signal?
{
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
Serial.println("Button Pressed!...");
break;
}
}
Serial.println("Stealth Mode Time Over");
delay (10);
irrecv.enableIRIn();
}
Does anyone have any thoughts on how to stop these ‘phantom presses’, or any idea what might be causing them?
Thanks,
Paul