Hello,
I build the circuit for control RGB led strip with arduino using mosfets's 4 color woks great RED, GREEN, BLUE, WHITE.
But when i change to another color like PURPLE it freeze and doesn't take any command.
i have inculde my code here.
Moderators note: used code tags
I build the circuit for control RGB led strip with arduino using mosfets's 4 color woks great RED, GREEN, BLUE, WHITE.
But when i change to another color like PURPLE it freeze and doesn't take any command.
i have inculde my code here.
C:
#include <IRremote.h>
int redPin = 9;
int bluePin =10;
int greenPin = 11;
int RECV_PIN = 6;
int before;
int bright;
int bright1;
int steps = 10;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup(){
irrecv.enableIRIn();
before = 0;
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop(){
if (irrecv.decode(&results)){
if(results.value == FFBA45){
if(bright1-255/steps<0){
analogwrite
}
}
if (results.value == 0xFF02FD){
if ( before == 0){
allcolor(255,255,255);
before = 1;
}
else{
allcolor(0,0,0);
before = 0;
bright = bright1;
}
}
if (before == 1){
if( results.value ==0xFF1AE5){
allcolor(255, 0, 0);
bright = bright1;
}
}
if(before ==1){
if(results.value == 0xFF9A65){
allcolor(0, 255, 0);
bright = bright1;
}
}
if (before == 1){
if(results.value == 0xFFA25D){
allcolor(0, 0, 255);
bright = 255;
}
}
if (before == 1){
if(results.value == 0xFF2AD5){
allcolor(153, 139, 88);
bright = bright1;
}
}
if (before == 1){
if(results.value == 0xFFAA55){
allcolor(88, 153, 93);
bright = bright1;
}
}
irrecv.resume();
}
}
void allcolor (int red, int green, int blue){
#ifdef COMMON_ANODE
red = 255 - red;
green = 255 - green;
blue = 255 - blue;
#endif
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}
Last edited by a moderator: