Hello. Im trying to do a kind of timer, where I press a button on the remote control, and I get beeps for 5 seconds, and the I get tons of beeps, until one button on the IRemote is pressed. I've tried this using a "if" loop for determining when the button is pressed, and then having the while loop for the "tons of beep". The problem is that the while loop can't be finished if the results.value does not change, something Im unable to do I dont know why. Even if I press differents buttons, in the while loop it keeps printing the same results.value. How can I get the arduino to not keep showing the same results.value, even if im pressing another button?
#include <IRremote.h>
int RECV_PIN = 3;
IRrecv irrecv(RECV_PIN);
decode_results results;
int buzzerPin = 4;
boolean soundRemember = false; // to remember when the sound is activated or not
int counterCron;
void setup() {
Serial.begin(9600);
pinMode(buzzerPin, OUTPUT);
irrecv.enableIRIn();
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume();
if (results.value == 0xFF02FD && soundRemember == false) {
soundRemember = true;
for (counterCron = 0; counterCron < 5; counterCron++) { // a whistle for every second, 5 times
Serial.println(results.value, HEX);
tone(buzzerPin, 100);
delay(500);
noTone(buzzerPin);
delay(500);
}
while (soundRemember == true && results.value != 0xFF025D) {
Serial.println(results.value, HEX);
tone(buzzerPin, 100);
delay(100);
noTone(buzzerPin);
delay(100);
irrecv.resume();
}
soundRemember = false;
irrecv.resume();
}
}
}