So my goal here is to run a servo when an IR (remote) signal is received. The problem is that whenever I use the remote, which obviously broadcasts the code quite frequently, the servo (the open() program) runs however many times the code is received, usually between 3 and 5 times. This is the part of the code that actually activates the open program when the remote button is pushed.
void loop(){
keypad.getKey(); //not important for this question
if (irrecv.decode(&results)){ //gets results
Serial.println(results.value); //prints to serial monitor (useful for adding buttons)
if (results.value == 554162470); //checks for results of the desired button
{
open(); //runs another program dealing with a servo
}
}
}
Is there a spot in there to set a delay? As far as I know the ir library that I'm using doesn't have a debounce function.
void loop(){
keypad.getKey(); //not important for this question
if (irrecv.decode(&results)){ //gets results
Serial.println(results.value); //prints to serial monitor (useful for adding buttons)
if (results.value == 554162470); //checks for results of the desired button
{
open(); //runs another program dealing with a servo
delay(5000); //does nothing for 5 seconds
}
}
}