Controlling Led Strip

Hi!
I want to control my LED strip with esp8266 and i’ve managed to control color of it with 3 sliders in my app (V1,V2,V3) and now I want to be able to turn on some animations on it and animation pin would be V4 and I want it to behave like this: When I press button [for example animation 1] it will ignore sliders and just show animation but when i move any slider it automaticlly disables animations and show solid color. This is my code so far and I’m really struggling to make it work.


#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "xxx-xxx-xxx-xxx";
char ssid[] = "XYZ";
char pass[] = "XYZ";


BlynkTimer timer;

void myTimerEvent(){
  
Blynk.syncVirtual(V1, V2, V3, V4);

}

BLYNK_WRITE(V1)
{
  int r = param.asInt(); 
  analogWrite(16,1020-r);
}

BLYNK_WRITE(V2)
{
  int g = param.asInt(); 
  analogWrite(5,1020-g);
}

BLYNK_WRITE(V3)
{
  int b = param.asInt(); 
  analogWrite(4,1020-b);
}

BLYNK_WRITE(V4)
{
  int ani = param.asInt(); 
  switch (ani) {
  case 1:
  //animation 1
    break;
  case 2:
  // animation 2
    break;
  }  
  case 3:
  // animation 3
    break;
  }  
}






void setup()
{

  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  timer.setInterval(100L, myTimerEvent);
}

void loop()
{
  Blynk.run();
  timer.run();
}

What’s your logic behind calling this function every 100ms?
What do you think the effect of this is?

Pete.

Because I want to control it with Node Red as well and without it when I change Virtual Pin value with Node red It looks like only app upadates on this value and the esp8266 not.

If you’re using Node-Red then my advice would not to run any Blynk code on the device, but to use MQTT code on your device and do the Blynk 8ntegratikn in Node-Red.

If you don’t take this approach then you need to stop doing the Blynk.syncVirtual calls every 100ms in your code and handle the synchronisation correctly in Node-Red, probably by using a Bridge node.

Pete.

Do you mean this node-red-contrib-blynk-bridge? And if so are there any tutorials how to use it or do i have to figure it out by myself?

By the way Thx for help :smiley:

The only contrib you should be using with Blynk is the “node-red-contrib-blynk-ws”.
This contains a node called “bridge”, which may be the solution to your problem, but without more information about what you’re trying to do, the flow you are using and the issues you’re encountering then it’s impossible to say.

The help information attached to the node is quite useful.

Pete.

Ok I’ve managed to get rid off syncVirtual(). Do you have any concept for me to start on, how to do these animations?

I guess it depends on what sort of animations you’re looking for, and the type of strip you’re using, but there are quite a lot ofLED animation examples on this forum.

Pete.