Skip to Content
Circuitera

Filter held-button repeats with Arduino IRremote 4.x

Read the IRremote 4.7.1 repeat flag and distinguish a new command from a held-button repeat without comparing raw hex alone.

Treat a repeat frame according to the action

A toggle usually needs one event per press, while a volume control might intentionally repeat. On a decoded frame, test IRDATA_FLAGS_IS_REPEAT in the flags bitmask. A library repeat flag follows protocol and timing rules. It does not establish that every remote’s very fast tap sequence will be distinguishable.

Resume the receiver after each frame

For this bench diagnostic, use a compatible receiver output on D2 with the module’s appropriate supply and ground. Print the address and command only for recognized nonrepeat frames. Call resume() after every decoded frame, even a frame you ignore. A successful compile does not test reception. Check the baud rate and receiver pin order before changing protocol code.

Open the exact Uno example

A matching remote can print one address/command pair per distinct press. Hardware and protocol behavior remain bench checks.

#include <IRremote.hpp>

void setup() {
  Serial.begin(9600);
  IrReceiver.begin(2);
}
void loop() {
  if (!IrReceiver.decode()) return;
  const auto &data = IrReceiver.decodedIRData;
  if (data.protocol != UNKNOWN && !(data.flags & IRDATA_FLAGS_IS_REPEAT)) {
    Serial.print(data.address, HEX);
    Serial.print(' ');
    Serial.println(data.command, HEX);
  }
  IrReceiver.resume();
}

Verified with [email protected] on Uno R3 (2026-12-05 UTC). This check did not use physical hardware.

Continue learning

Sources