Can't sync GPIO state to widget button

Hi friends. I want to sync GPIO state with the widget button but can’t working. in the blow sketch when pirPin set to high then GPIO 4 (D2) go to low but the widget button (D2) can’t be sync.

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <SI7021.h>
#include <Wire.h>
#include <Adafruit_BMP085.h>
#include <BH1750.h>  
BH1750 lightMeter;

char auth[] = "fe5078fcb5f04f5384ac70cb9ab91697";                 //Put your blink token
char ssid[] = "MikroTik Tesla";                            //Put your SSID of your connection
char pass[] = "12345678";                            //Put your Password of your connection
char server[] = "";  

SI7021 sensor;

SimpleTimer timer;

#define I2C_SCL 12      //D6
#define I2C_SDA 13     //D7
#define ledPin 15
#define alarmPin 4
#define pirPin 14

Adafruit_BMP085 bmp;

float dst, bt, bp, ba, q;
char dstmp[20], btmp[20], bprs[20], balt[20];
bool bmp085_present = true;

int pirState;
int val;
int x;


 x = param.asInt();

void PIRval(){
val = digitalRead(pirPin);
    if (val == HIGH) {
      digitalWrite(ledPin, LOW);  
      else {
        digitalWrite(ledPin, HIGH); 

  void pir(){
  if (x == 1){
    if (digitalRead(pirPin) == HIGH){
 Blynk.notify("Alarm Enabled");
 digitalWrite(alarmPin, LOW);

void setup()
  Serial.begin(115200); // See the connection status in Serial Monitor
  Blynk.begin(auth, ssid, pass, server, 8080); //insert here your SSID and password
  Wire.begin(I2C_SDA, I2C_SCL);
if (!bmp.begin()) {
  Serial.println("Could not find a valid BMP085 sensor, check wiring!");
  //while (1) {}
  timer.setInterval(1000L, PIRval);
  timer.setInterval(1000L, pir);
  timer.setInterval(1000L, sendUptime);
  pinMode(ledPin, OUTPUT);
  pinMode(alarmPin, OUTPUT);
  pinMode(pirPin, INPUT);
  digitalWrite(alarmPin, HIGH);

void sendUptime()
  float temperature = sensor.getCelsiusHundredths();
  float humidity = sensor.getHumidityPercent();

  Blynk.virtualWrite(5, (float)temperature/100); 
  Blynk.virtualWrite(6, humidity); // virtual pin

  uint16_t lux = lightMeter.readLightLevel();
  Blynk.virtualWrite(4, lux);

  float bp =  bmp.readPressure();

  float ba =  bmp.readAltitude();
  Blynk.virtualWrite(7, ba);

  float bt =  bmp.readTemperature();
  Blynk.virtualWrite(12, bt);

  float dst =  bmp.readSealevelPressure(520)/100;
  Blynk.virtualWrite(13, dst);

  float q = analogRead(A0);
  Blynk.virtualWrite(2, q);

  float val = digitalRead(pirPin);
  Blynk.virtualWrite(3, val);


void loop()

You need to set the virtual button low as well, Blynk.virtualWrite(VX, 0); after you change your GPIO4