ESP8266 MQTT lamps

Hey there !

I just spent a few days on this project from Instructables.

Everything is working great, but I can't achieve what I want to do with those lamps. The LEDs are actually always on, & switch on colors by touching the sensor; but what if I want the LEDs to be always off, & to switch on/change color ONLY when I touch the sensor ?

I'm actually a total begnner in this coding/soldering stuff, & trying to learn; but my brain can't succeed :-[

Here's the code used by the creator.
I tried to contact him via Instructables, but no answer, that's why I'm requesting some help here. I guess there's just some little things to tweak, but, no, I definitely can't find the issue by my own..

Thanks for your kind help, & sorry for my english. I swear I did my best :-[

Here's the code used by the creator.

But it's YOUR code that isn't working. Post that code.

My code is in attachment !

I didn’t change much, but MQTT’s topics names & LEDs swooshes speed :smiley:
Once again, both of the lamps are working with this code. I just want them to be turned off when the sensor is released.

synclamps.ino (10.8 KB)

Why did you not post code that will compile?

}

vi

void loop() {
  long startTime = millis();
    char payload[1];

There is just NO excuse for creating a one element array.

    itoa(hue, payload, 10);

You values in hue range from 0 to 360. That requires an array size of at least 4. You just sh*t on memory you don't own.

  if (sensorValue > SENSOR_THRESHOLD) {

If the value exceeds the threshold, do some stuff.

  // For determining first loop after touch is released
  if (sensorValue > SENSOR_THRESHOLD) {

Then, check to see if the value is still above the threshold...

Since the value hasn't changed, the second test is going to evaluate EXACTLY the same as the first one.

I just want them to be turned off when the sensor is released.

So, where is the code to do that?