I’m wondering about a similar problem with a philips lightstrip plus
these are 5 channel ledstrips
I’ve managed to get the colors and warmwhite/coldwhite channels going with this sketch
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
// ESP-12 LoLin v3 (nodemcu 0.9) used in this example
// RGB FET
#define redPin 16 //Red, obviously
#define greenPin 5 //G
#define bluePin 4 //B
#define wwhitePin 2 // Warm White
#define cwhitePin 0 // Cold White
int wait = 2000;
const char *ssid = "ssid"; // cannot be longer than 32 characters!
const char *pass = "pass";
const char *logtopic = "/esp8266/log";
const char *pubtopic = "/home/in/esp8266_5";
const char *subtopic = "/home/out/esp8266_5";
// Update these with values suitable for your network.
IPAddress broker(192, 168, 1, 253);
void callback(const MQTT::Publish& pub) {
// handle message arrived
}
WiFiClient wclient;
PubSubClient client(wclient, broker);
void setup()
{
Serial.begin(115200);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(wwhitePin, OUTPUT);
pinMode(cwhitePin, OUTPUT);
InitWiFi();
}
void loop()
{
if (client.connected())
client.loop();
Serial.println("red:");
setColor(1023, 0, 0, 0, 0); // red
delay(wait);
Serial.println("green:");
setColor(0, 1023, 0, 0, 0); // green
delay(wait);
Serial.println("blue:");
setColor(0, 0, 1023, 0, 0); // blue
delay(wait);
Serial.println("yellow:");
setColor(512, 512, 0, 0, 0); // yellow
delay(wait);
Serial.println("magenta:");
setColor(512, 0, 512, 0, 0); // magenta
delay(wait);
Serial.println("cyan:");
setColor(0, 512, 512, 0, 0); // cyan
delay(wait);
Serial.println("composite white:");
setColor(341, 341, 341, 0, 0); // composite white
delay(wait);
Serial.println("warm white:");
setColor(0, 0, 0, 1023, 0); // cold white
delay(wait);
Serial.println("cold white:");
setColor(0, 0, 0, 0, 1023);
delay(wait);
Serial.println("coldest white:");
setColor(0, 0, 512, 0, 512);
delay(wait);
}
bool InitWiFi() {
if (WiFi.status() != WL_CONNECTED) {
setColor(1023, 0, 0, 0, 0); // red
delay(1000);
setColor(0, 0, 0, 0, 0); // green
delay(1000);
Serial.print("Connecting to ");
Serial.print(ssid);
Serial.println("...");
if (WiFi.status() != WL_CONNECTED) {
setColor(1023, 512, 0, 0, 0); // red
delay(1000);
setColor(0, 0, 0, 0, 0); // green
delay(1000);
}
WiFi.begin(ssid, pass);
if (WiFi.waitForConnectResult() != WL_CONNECTED)
return 1;
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.println("");
}
if (WiFi.status() == WL_CONNECTED) {
if (!client.connected()) {
if (client.connect("arduinoClient")) {
setColor(0, 1023, 0, 0, 0); // green
delay(wait);
setColor(0, 0, 0, 0, 0); // green
delay(wait);
client.publish(logtopic,"Wi-fi connected, boot message sent.");
client.subscribe(subtopic);
return 0;
}
}
}
}
void setColor(int red, int green, int blue, int wwhite, int cwhite)
{
client.publish(logtopic,"Setting color");
analogWrite(redPin, red);
Serial.print("R: ");
Serial.print(red);
analogWrite(greenPin, green);
Serial.print(" G: ");
Serial.print(green);
analogWrite(bluePin, blue);
Serial.print(" B: ");
Serial.print(blue);
analogWrite(wwhitePin, wwhite);
Serial.print(" W: ");
Serial.print(wwhite);
analogWrite(cwhitePin, cwhite);
Serial.print(" C: ");
Serial.println(cwhite);
}
I’ve been using this example
It works, but I need an extra channel for the warm/cold whites. I’d also like to make it simpler