Virtual trigger calls the function twice

For my project i have used virtual pins to call the function
But instead of calling the the function just one it is recalled two time in my particle photon
For example when i try to blink an led once in the function, called through the virtual pin. it completes the cycle once and is again called. So basically the led blinks twice.


Are you using a button widget and is it PUSH or SWITCH mode?
You should be able to code a single blink.

i am using push mode for the blynk ]

PUSH means go high and then go low, perhaps this is why you are seeing 2 entries.

Can you post an extract of your Blinking code.

this is the code that i used in project as simple tigger to give led a signal.

// This #include statement was automatically added by the Particle IDE.
#include “Adafruit_DHT/Adafruit_DHT.h”

// This #include statement was automatically added by the Particle IDE.
#include “blynk/blynk.h”
#define DHTPIN 5
#define DHTTYPE DHT11

// Variables
int temperature;
int humidity;

// Pins

// DHT sensor

char auth[]=
void setup() {
pinMode(D0, OUTPUT);


void loop() {;

 temperature = dht.getTempCelcius();

// Humidity measurement
humidity = dht.getHumidity();

int temp= temperature;
Blynk.virtualWrite(V1, temp);
int hum = humidity;
Blynk.virtualWrite(V2, hum);

digitalWrite(D0, HIGH);
digitalWrite(D0, LOW);
digitalWrite(D0, HIGH);
digitalWrite(D0, LOW);


So many problems. You can’t use Arduino sketches without updating them for use with Blynk.

You don’t post code like that on any forum

Don’t publish your security credentials on an open forum.

Study all the docs and good selection of the examples.

oo the code run fine but the last, the last function is some how running two times.
every time i push the button

it is not running fine, just trust me on that one.

delay() is “not allowed” with Blynk.

The developers went to great time and effort to write dozens of sketches for beginners to use their system. At least one shows you how to correctly blink LEDs with Blynk.

ooo ok. didnt know about the delay sorry really new to these stuff
could u suggest any one example for the trigger or blink led
would be a great help

No I’m going let you find them. It’s not difficult.

You should add to the code block the if statement with asInt() method parameter to prevent double (twice) calling. It’s cuz, you receive data from Virtual Pin and here is need to convert to integer or receive like integer variable. For example, controlling physical GPIO18 via V3 virtual pin:

#define GPIO18 18

  if (param.asInt()) {
    digitalWrite(GPIO18, LOW);
    // delay(1000);    ==> millis()
    digitalWrite(GPIO18, HIGH);

@AVicenNA please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:


Hopefully, after 4 years the OP has either figured this out or found a workaround.


1 Like