2

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)?

1

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 '17 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 '17 at 1:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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