I am trying to control my WS2812B with a remote control. To archive this, I am using IRRemote library. The problem is that this two libraries doesn't work together.

I did some research and found out that it is a problem with timers.But, inside the IRRemote library file (boarddefs.h) there is a possibility to choose different timer (It uses TIMER2 as default, so I supposed that FastLed uses also Timer2).

So when I change the timer in boarddefs.h file to TIMER1, it is also now working fine for me. I keep recieving random IR codes. When I stop using FastLed library, I recive correct codes.

Some workaround to this problem is to read IR signal only once irrecv is idle:

  while (!irrecv.isIdle());  // if not idle, wait till complete
  if (irrecv.decode(&results)) {

It makes around 80% of readings correct.

I am using arduino NANO clone. My question is, if there is any way to use IRRemote and FastLed libraries together other than using two arduino NANO (use one to read IR and other to control LEDs)?

3 Answers 3


update in 2021, similar problem, fastLED causing unintelligible IR codes, adding that while loop:

while (!irrecv.isIdle());  // if not idle, wait till complete

just before the ir check worked for me, not 100% of the codes are correct but more than good enough for my use, you life saver


The WS2812B chips are highly timing-dependent. You have to clock out bits within a range of ±150 ns. This isn't likely to work well with clocking in bits from an IR remote. You are finding errors on the IR codes - that doesn't surprise me.

I suggest you use your idea of two Nanos. One can be reading IR codes. The other can display a stream of pixels and then "ask" the other one (eg. via serial or I2C) if a different command has arrived. That way the timing can be shifted in such a way that both processors are not interrupted when they are busy.

  • But as I read, Arduino NANO can use two or even three timers. I do not fully understand timer topic, but what I understand is, than I could use timer1 for LED and timer2 for IRRemote - but it does not work...
    – Marek
    Feb 10, 2017 at 21:52
  • Yes, but just having timers doesn't necessarily solve your problem. You are clocking out bits to the WS2812B every 350 ns or so. That doesn't give you spare time to read incoming IR bits, timer or not.
    – Nick Gammon
    Feb 11, 2017 at 1:49

I want to add my two cents at the solution posted bt @BenAshmore, that allow to mediate between fast updates and receiving sensible data:

void loop() {
    if( IrReceiver.decodedIRData.protocol == UNKNOWN ){
        Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX); 
    IrReceiver.resume(); // Enable receiving of the next value
  if(!wantData || IrReceiver.isIdle() ){

basically if I receive messy IR data I know there is something incoming and just in that case I interrupt the FastLed updating until I read something good.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.