Hello !
I have a problem with the synchronization of virtual pins.
I use an Arduino Nano with a HC08 BLE module and a direct connect with iOS 14.0 to deal with strip led (on/off, some animation, and custom RGB color with sliders)
I can sync all the widget on connection, the BLYNK_WRITE(XX) is never call after the sync.
The widget are in the right position, but I have to click button or slide a slider tu trigger the BLYNK_WRITE(XX).
My virtualpin V1 is a menu with some animation.
I want to restore the last animation when i’m connect to Blynk.
My question is: It’s possible to put my strip led to the last state without touch manually a widget?
here is my code (simplified):
#define BLYNK_USE_DIRECT_CONNECT
#include <BlynkSimpleSerialBLE.h>
BlynkTimer timer;
// RGB Lights
#include <Adafruit_NeoPixel.h>
#define NUM_LEDS 36
#define PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxx"; // Nano
BLYNK_CONNECTED() {
Serial.println("CONNECTED");
Blynk.syncVirtual(V0, V1);
Blynk.run();
}
void setup()
{
// Blynk will work through Serial
// Do not read or write this serial manually in your sketch
Serial.begin(9600);
strip.begin();
strip.setBrightness(50);
for (int x = 0; x < NUM_LEDS; x++) {
strip.setPixelColor(x, 50, 0, 0);
};
strip.show();
Blynk.begin(Serial, auth);
}
void loop()
{
Blynk.run();
timer.run();
activity(current_activity);
}
void activity(int activity_button) {
// Switch / case to select activity
}
BLYNK_WRITE(V0) { //ON Off
Serial.println("CALL V0");
if (param.asInt()) {
lamp_on = 1;
}
else {
all_lights(0);
lamp_on = 0;
}
}
BLYNK_WRITE(V1) { //Activity slider
Serial.println("CALL V1");
current_activity = param.asInt();
}
In the Serial monitor I just show CONNECTED from BLYNK_CONNECTED() But I never show my CALL from BLYNK_WRITE(XX).
Any suggestion??
Thank you !