Hi everyone. I’m trying to get an LED strip to chase and change color using my Arduino ESP 32 board and a strip of RGBW led strips. So far I have the app running perfectly to control the color with one virtual pin. Switch to white with another virtual pin. The issue I’m having is I would like for when I hit V3 that what ever color is currently selected will chase continuously until V3 is selected again. Right now when I hit V3 the chase starts and works great. The issue I have is it does two cycles and stops and when its running the chase it disregards all inputs until the chase is complete. I’m really new to arduino and blynk and hoping someone can help me. I have included the code I’m using so far…
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <Adafruit_NeoPixel.h>
#define PIN 15
#define NUM 25
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM,PIN, NEO_GRBW + NEO_KHZ800);
char auth[] = "**********************";
char ssid[] = "Cormacs";
char pass[] = "*********";
int r,g,b,data;
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
pixels.begin();
}
void loop()
{
Blynk.run();
}
BLYNK_WRITE(V2)
{
r = param[0].asInt();
g = param[1].asInt();
b = param[2].asInt();
if(data==0)
static1(r,g,b);
}
BLYNK_WRITE(V3)
{
data = param.asInt();
Serial.println(data);
if(data==1)
{
animation1();
}
else if(data==0)
{
static1(r,g,b);
}
}
BLYNK_WRITE(V1)
{
for(int i=0;i<=NUM;i++)
{
pixels.setPixelColor(i, pixels.Color(1023,1023,1023,1023));
pixels.show();
}
}
void static1(int r, int g, int b)
{
for(int i=0;i<=NUM;i++)
{
pixels.setPixelColor(i, pixels.Color(r,g,b));
pixels.show();
}
}
void animation1()
{
for(int i=0;i<NUM;i++)
{
pixels.setPixelColor(i, pixels.Color(0,0,0));
pixels.show();
delay(100);
}
for(int i=NUM;i>=0;i--)
{
pixels.setPixelColor(i, pixels.Color(r,g,b));
pixels.show();
delay(100);
}
for(int i=0;i<NUM;i++)
{
pixels.setPixelColor(i, pixels.Color(0,0,0));
pixels.show();
delay(100);
}
for(int i=NUM;i>=0;i--)
{
pixels.setPixelColor(i, pixels.Color(r,g,b));
pixels.show();
delay(100);
}
}