BlynkEdgent - const char* does not work in functions BLYNK_CONNECTED

Good afternoon!
Gentlemen developers please explain the following question:

code (Arduino IDE) - code does not work
const char* blynkVirtualPin[8] = {“V0”,“V1”,“V2”,“V3”,“V4”,“V5”,“V6”,“V7”};

    #include "BlynkEdgent.h"

    BLYNK_CONNECTED()
    {
    Blynk.syncVirtual(blynkVirtualPin[0]);
    Blynk.syncVirtual(blynkVirtualPin[1]);
    Blynk.syncVirtual(blynkVirtualPin[2]);
    Blynk.syncVirtual(blynkVirtualPin[3]);
    Blynk.syncVirtual(blynkVirtualPin[4]);
    Blynk.syncVirtual(blynkVirtualPin[5]);
    Blynk.syncVirtual(blynkVirtualPin[6]);
    Blynk.syncVirtual(blynkVirtualPin[7]);
    }

code - good working

#define blynkVirtualPin_1
#define blynkVirtualPin_2
#define blynkVirtualPin_3
#define blynkVirtualPin_4
#define blynkVirtualPin_5
#define blynkVirtualPin_6
#define blynkVirtualPin_7
#define blynkVirtualPin_8

#include "BlynkEdgent.h"

BLYNK_CONNECTED()
        {
        Blynk.syncVirtual(blynkVirtualPin_1);
        Blynk.syncVirtual(blynkVirtualPin_2);
        Blynk.syncVirtual(blynkVirtualPin_3);
        Blynk.syncVirtual(blynkVirtualPin_4);
        Blynk.syncVirtual(blynkVirtualPin_5);
        Blynk.syncVirtual(blynkVirtualPin_6);
        Blynk.syncVirtual(blynkVirtualPin_7);
        Blynk.syncVirtual(blynkVirtualPin_8);
        }

Please explain the reason

There’s a much simpler way…

BLYNK_CONNECTED()
{
  for(int loop = 1; loop <=  8; loop++)
  {
    Blynk.syncVirtual(loop);
  }
}

or, you can turn on the “Sync with latest server value every time device connects to the cloud” option in the advanced datastream settings for each datastream you wish to synchronise…

then use Blynk.syncAll()

BLYNK_CONNECTED()
{
  Blynk.syncAll();
}

Pete.

thanks!

1 Like