Trying to make IR controlled RGB strip. PWM pins of micro are connected to n-channel mosfet-s.
Everything works as expected only blue (pin 10) wont change brightness gradually, just from 0 to 100 and then if increased to 255. Tried to move to pin 3 but same thing happens.
#define DECODE_RC5
#include <Arduino.h>
#include "PinDefinitionsAndMore.h"
#include <IRremote.h>
int bila = 6;
int crvena = 3;
int zelena = 9;
int plava = 10;
int r = 5;
int g = 5;
int b = 5;
int w = 5;
void setup() {
pinMode(bila, OUTPUT);
pinMode(crvena, OUTPUT);
pinMode(zelena, OUTPUT);
pinMode(plava, OUTPUT);
Serial.begin(115200);
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK, USE_DEFAULT_FEEDBACK_LED_PIN);
}
void loop() {
analogWrite(plava, b);
analogWrite(bila, w);
analogWrite(crvena, r);
analogWrite(zelena, g);
if (r < 0) {r = 0;}
if (r > 255) {r = 255;}
if (g < 0) {g = 0;}
if (g > 255) {g = 255;}
if (w < 0) {w = 0;}
if (w > 255) {w = 255;}
if (b < 0) {b = 0;}
if (b > 255) {b = 255;}
if (IrReceiver.decodedIRData.command == 0x1) {
w = w - 1;
} else if (IrReceiver.decodedIRData.command == 0x3) {
w = w + 1;
}else if (IrReceiver.decodedIRData.command == 0x2) {
w = 30;
}else if (IrReceiver.decodedIRData.command == 0x4) {
r = r - 1;
} else if (IrReceiver.decodedIRData.command == 0x6) {
r = r + 1;
}else if (IrReceiver.decodedIRData.command == 0x5) {
r = 30;
}else if (IrReceiver.decodedIRData.command == 0x7) {
g = g - 1;
} else if (IrReceiver.decodedIRData.command == 0x9) {
g = g + 1;
}else if (IrReceiver.decodedIRData.command == 0x8) {
g = 30;
}else if (IrReceiver.decodedIRData.command == 0x26) {
b = b - 1;
} else if (IrReceiver.decodedIRData.command == 0x22) {
b = b + 1;
}else if (IrReceiver.decodedIRData.command == 0x11) { // volume down button
r = r - 1;
g = g - 1;
w = w - 1;
b = b -1
} else if (IrReceiver.decodedIRData.command == 0x10) { // volume up button
r = r + 1;
g = g + 1;
w = w + 1;
b = b + 1;
}
else if (IrReceiver.decodedIRData.command == 0xC) {
b = 0;
r = 0;
g = 0;
w = 0;
}
else if (IrReceiver.decodedIRData.command == 0x35) {
fade(); // this function is empty for now
}
IrReceiver.resume();
}
???
p.s. ir receiver is connected to pin 2.