I am relatively new at Arduino but I have basic skills in programming and electronics from before. I am also relatively good at googling. I have read up quite a bit on this problem but still found no suggestion of a solution.
I am trying to control an RGB-LED with an remote control and an IR-receiver connected to an Arduino R3. The ultimate goal is to produce a "magic staff with a glowing crystal". The remote has 17 buttons and I can decode them without problem, using Shariffs IRremote library.
Some of the functions I want the staff/LED to do is:
For any or all colors: dim to 0, dim up to max, dim down a bit, dim up a bit. Also for all colors: Immediate White/off.
IRreciever is on pin 11. LED is on pins 9, 10 and 6 (NOT 11, since timer2 is used by the library - I am aware of this) (Putting the receiver on pin 2 makes no difference, as it shouldn't).
It now turns out that all actions that leave the PWM pins at 0 or 255 works just fine. However, as soon as any of the upabit() or downabit() are used which leave the pins at levels not equal to 0 or 255, the next IR signal cannot be properly decoded. In fact, all key presses on the remote after that crucial function call decode simply as random codes.
In other words, "floating" or "active" PWM pins seems to disturb the IRRemote library, or at least the resume() method.
It seems to be some sort of interference with timing/timers, but according to what I know, only timer2 is used which only affects pins 3 and 11. Other pins are not affected in theory, and in practice, they work too. Its just that they somehow affect the library functions back.
Is there any way to get around or solve this problem? Or am I just incredibly stupid and have missed something obvious? Has anyone else managed to do what I am doing?
Code follows.