i am new to arduino and looking for code that can control two colour LED STRIP i.e. white and warm white . i know the hardware part by using the correct MOSFET , Resitors and capacitors along with the arduino nano. but as i am not into coding i will grateful if you can provide me the code. following is what i am looking for :
-controlling the lights via IR remote which includes :
-on/off
PWM dimming
-control white light from warm white to cool white (2700K-6500K)
-memory function (if possible)
hi i tried to search on google before making a post here but most of them codes are either for controlling RGBs with multiple effects or for controlling WS2812led strips. i cant find anywhere that can control CCT strips with IR
my friend i have found the closest code and when i am trying to run it , nothing is happening on arduino . following is my code :
//https://www.youtube.com/user/greatscottlab
#include <IRremote.hpp>
int bright;
int before;
int out=9; //connect your LED to pin 9
int steps=5; //dimmer steps, vary those to increase/decrease the steps between full brightness and turned off
const int RECV_PIN = 11; //data out of IR receiver connects to pin 11
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup(){
irrecv.enableIRIn(); // start the receiver
before=0; //LED is turned off
bright=255; //brightness value is at maximum (255)
pinMode(out,OUTPUT);
}
void loop() {
if (irrecv.decode(&results)) {
if (results.value==0x20DF8D72){ //Code to turn the LED ON/OFF
if(before==0){ // if the LED was turned off, then we turn it on
digitalWrite(out,HIGH);
before=1; //LED is now turned on
}
else{
digitalWrite(out,LOW); //if the LED was turned on, then we turn it off
before=0;
bright=255;
}}
if (results.value==0x20DFF10E && before==1){ //Code to decrease the brightness
if(bright-255/steps<0){
analogWrite(out,bright);
}
else{
bright=bright-255/steps;
analogWrite(out,bright);
}}
if (results.value==0x20DF718E && before==1){ //Code to increase the brightness
if(bright+255/steps>255){
analogWrite(out,bright);
}
else{
bright=bright+255/steps;
analogWrite(out,bright);
}}
irrecv.resume();
}}
after spending almost whole day , following is my code :
#include <IRremote.h>
int out=9;
int out2=6;
int before;
int white;
int yellow;
int steps=5;
const int IR_RECEIVE_PIN = 10;
void setup() {
Serial.begin(115200); //Start Serial monitor in 115200
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
before=0; //LED is turned off
white=255;
yellow=255;
pinMode(out,OUTPUT);
pinMode(out2,OUTPUT);
}
void loop() {
if (IrReceiver.decode()) {
// value from receiver in Living room
if (IrReceiver.decodedIRData.decodedRawData == 0xED127F80) {
if(before==0){
digitalWrite(out,HIGH);
before=1;
}
else {
digitalWrite(out,LOW);
digitalWrite(out2,LOW);//if the LED was turned on, then we turn it off
before=0;
white=255;
yellow=255;
}}
if (IrReceiver.decodedIRData.decodedRawData == 0xFD027F80 && before==1){ //Code to switch to yellow tone
if(white-255/steps<0 && yellow+255/steps>255){
analogWrite(out,white);
analogWrite(out2,yellow);
}
else{
white=white-255/steps;
yellow=yellow+255/steps;
analogWrite(out,white);
analogWrite(out2,yellow);
}}
if (IrReceiver.decodedIRData.decodedRawData == 0xFC037F80 && before==1) { //Code to switch to white tone
if(white+255/steps>255 && yellow-255/steps<0){
analogWrite(out,white);
analogWrite(out2,yellow);
}
else{
white=white+255/steps;
yellow=yellow-255/steps;
analogWrite(out,white);
analogWrite(out2,yellow);
}}
if (IrReceiver.decodedIRData.decodedRawData == 0xFA057F80 && before==1){ //Code to decrease the brightness
if(white-255/steps<0 && yellow-255/steps<0){
analogWrite(out,white);
analogWrite(out2,yellow);
}
else{
white=white-255/steps;
yellow=yellow-255/steps;
analogWrite(out,white);
analogWrite(out2,yellow);
}}
if (IrReceiver.decodedIRData.decodedRawData == 0xF9067F80 && before==1) { //Code to increase the brightness
if(white+255/steps>255 && yellow+255/steps>255){
analogWrite(out,white);
analogWrite(out2,yellow);
}
else{
white=white+255/steps;
yellow=yellow+255/steps;
analogWrite(out,white);
analogWrite(out2,yellow);
}}
}
IrReceiver.resume();
}
now i am stuck at this point where i cant control the tone of colour , when i try to increase the brightness , both colour led turns on