Code for controlling White and Warm White led strip

hi friends,

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)

a similar CCT controller is also available in market like here :
https://www.amazon.in/Protium-12-24V-Tunable-controller-assistant/dp/B0B1F6QBWY

but because i want to control the lights via my own remote and on some customisations thats why i want to choose the arduino way.

PS i know the remote hex codes so you can leave it blank

thank you so much for reading and helping in advance

I googled "Arduino remote control" and came up with 29,000,000 hits.
Have you tried any of them?

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

You may not find exactly what you want but it is basically the same as using PWM for RGB, except you have PWM for 2 different CCT strips.

hi,

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

Please Help me .

thank you

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.