Hi, I need help with an error that I really can't understand. I wanted to program an RGB led in fade mode. So I looked for the code to replicate the effect, I tried it directly with the led connected to Arduino and it worked, all the colors alternated smoothly as the fade effect should be. So I decided to have the effect activated with an IR remote control. But even just adding " irrecv.enableIRIn (); " in the setup, the effect no longer worked, or rather it worked halfway, to be exact, the red color was not completely turned on by skipping all the shades. Just remove that line of code irrecv.enableIRIn (); and the effect worked again, I can't understand. Thanks in advance. This is the code:
#include "IRremote.h"
IRrecv irrecv(receiver);
decode_results results;
int redPin = 3;
int greenPin = 5;
int bluePin = 10;
void setup(){
irrecv.enableIRIn();
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop(){
for(int i = 0; i < 256; i++){
rgb(255-i, i, 0);
delay(10);
}
for(int i = 0; i < 256; i++){
rgb(0, 255-i, i);
delay(10);
}
for(int i = 0; i < 256; i++){
rgb(i, 0, 255-i);
delay(10);
}
}
void rgb(int red, int green, int blue){
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}
(code tags added by Moderator - next time use the </> button on the menu please.)