Counter with blynk

Hi.
I have a simple application at standalone esp8266 with one digital button GPIO0. I need to make a couter and should now, how many times the users clicked them. I don’t know how to make the “if part”. Please advice.

#define BLYNK_PRINT Serial

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

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = “”;

// Your WiFi credentials.
// Set password to “” for open networks.
char ssid[] = “”;
char pass[] = “”;

int counter = 0; // Set counter to 0
int button =0; // Set button to GPIO0

if …
counter++;
Blynk.virtualWrite(V5, counter);

{
// This command writes Arduino’s uptime in seconds to Virtual Pin (5)
Blynk.virtualWrite(V5, millis() / 1000);
}

void setup()
{
// Debug console
Serial.begin(9600);

Blynk.begin(auth, ssid, pass);
}

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

Look for examples that talk about debouncing,
use analogRead(button); to get the button value - you will find such statements in the debounce examples.
call such code from your loop()

once debounced your code:

counter++;
Blynk.virtualWrite(V5, counter);

should be fine

Thank’s for your message, the button will be virtual at blynk, not physical, how should I change the code?

In that case, use a virtual pin rather than a digital pin.

Pete.