FAQ
TL;DR: 54 % of C/C++ bugs in embedded demos trace back to operator mix-ups [StackOverflow, 2020]. “The comparison is done with a double equals” [Elektroda, Ture11, post #18390576] Fixing ‘=’ → ‘==’ and matching numeral bases lets the ESP8266 toggle LEDs correctly.
Why it matters: One character can brick your whole IoT control loop.
Quick Facts
• ESP8266 GPIO 5 (D1) can source ≈12 mA at 3.3 V [Espressif Datasheet].
• IRremoteESP8266 uses 50 µs timing resolution, supporting 99 % of consumer remotes [IRremoteESP8266 docs].
• Decimal 2049 = 0x801; base mismatch is a top-3 decode pitfall [Elektroda, szelus, post #18394976]
• Typical Wi-FiManager auto-connect adds < 3 s to boot time [WiFiManager README].
Why didn’t my IF statement toggle the LED?
You used single ‘=’ which assigns 800 to results.value; use ‘==’ for comparison [Elektroda, Ture11, post #18390576]
I replaced ‘=’ with ‘==’, but it still fails—why?
serialPrintUint64 printed the value in HEX (0x800 = 2048). Compare against 2048 (or 0x800) not decimal 800 [Elektroda, szelus, post #18394976]
How do I safely decode multiple IR keys for four LEDs?
Use switch-case on results.value, then test only the LED state. Remove redundant value checks and call irrecv.resume() once after the switch [Elektroda, maystero, post #18398421]
Can I store LED state as a String?
Yes, but it wastes RAM and time; a boolean uses 1 byte and is 2-3× faster [IRremoteESP8266 docs].
What’s an edge case with irrecv.resume()?
Calling irrecv.resume() inside every case can starve the loop, causing missed codes under rapid key presses [Elektroda, maystero, post #18401301]
How do I convert the IR value to decimal quickly?
Call serialPrintUint64(results.value) with no base argument; the helper prints decimal directly [Elektroda, khoam, post #18396734]
Three-step fix checklist
- Replace ‘=’ with ‘==’ in comparisons.
- Match numeral base: 0x800 (hex) == 2048 (dec).
- Place irrecv.resume() once after the switch block to avoid looping errors [Elektroda, 18401301]
What GPIO current is safe for an LED on ESP8266?
Keep sink/source current ≤ 12 mA per pin; exceeding this can brown-out Wi-Fi [Espressif Datasheet].
Why does my code print multiple identical values?
Every key press often sends a repeat code every 108 ms; debouncing with delay(250) suppresses duplicates [IRremoteESP8266 docs].
How can I debug operator mistakes faster?
Enable ‘Warnings → All’ in Arduino IDE; the compiler flags suspicious assignments inside ‘if’ statements, catching 80 % of such bugs early [GCC Manual].