Need help!

So I am making a separate lpg smoke and CO level checker using esp8266 and mq2 and blynk. so i have 2 buttons one for switiching on the lpg meter and another for switching smoke andd CO level. But the problem is that on switching one button the green led is flickering due to the else condition of the 2nd version and vice versa. So can anyone help me get a solution.
Here is my code:


#include <Servo.h> 
Servo myservo;

#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>

#define BLYNK_PRINT Serial


#define BLYNK_TEMPLATE_ID ""
#define BLYNK_DEVICE_NAME ""
#define BLYNK_AUTH_TOKEN ""

  
char auth[] = BLYNK_AUTH_TOKEN;// Enter your Auth token
char ssid[] = "bristidev-4G";//Enter your WIFI SSIS
char pass[] = "Br@190304";//Enter your WIFI password

BlynkTimer timer;

int pinValue = 0;
int pinValue1= 0;
int pinValue2= 0;
int pinValue3= 0;
int i=0;
#define Buzzer D5
#define Green D6
#define Red D7
#define Sensor A0
#define servo D3

#define fan D8
MQ2 mq2(Sensor);


void setup() {
  Serial.begin(9600);
  myservo.attach(servo);
  mq2.begin();
  pinMode(Green, OUTPUT);
  pinMode(Red, OUTPUT);
  pinMode(Buzzer, OUTPUT);
  pinMode(Sensor, INPUT);
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, notification);
}


BLYNK_WRITE(V4) {
  pinValue = param.asInt();
}


BLYNK_WRITE(V5) {
  pinValue1 = param.asInt();
}





void notification() {
  int sensor =analogRead(Sensor);
  float* values= mq2.read(true);
  
 
    
    if (pinValue == 1) {
    
      if (sensor <=260) {
        digitalWrite(Green, HIGH);
        digitalWrite(Red, LOW);
        digitalWrite(Buzzer, LOW);
        digitalWrite(fan,LOW);
        for(;i>=0;i--)
        {
          myservo.write(i);
          delay(50);
        }
        myservo.write(0);
        i=0;
      }
      
      else {
        Blynk.logEvent("lpg","Warning! Gas leak detected");
        digitalWrite(Green, LOW);
        digitalWrite(Red, HIGH);
        digitalWrite(Buzzer, HIGH);
        digitalWrite(fan,HIGH);
        i=90;
        myservo.write(90);
       
      }
     
      Blynk.virtualWrite(V3,sensor);
    } 
    
    else {
      digitalWrite(Red, LOW);
      digitalWrite(Buzzer, LOW);
      digitalWrite(Green, LOW);
      for(;i>=0;i--)
      {
        myservo.write(i);
        delay( 50);
      }
      i=0;
    }
  
  
  
  
    
    int sensor1=mq2.readSmoke();
    int sensor2=mq2.readCO();
   
    if(pinValue1==1)
    { 
        if (sensor1 <=5000)
        { 
          digitalWrite(Green, HIGH);
          digitalWrite(Red, LOW);
          digitalWrite(Buzzer, LOW);
          digitalWrite(fan,LOW);
          for(;i>=0;i--)
          {
            myservo.write(i);
            delay( 50);
          }
          i=0;
        }
     
        else {
          Blynk.logEvent("smoke","Warning! Excessive Smoke detected");
          digitalWrite(Green, LOW);
          digitalWrite(Red, HIGH);
          digitalWrite(Buzzer, HIGH);
          digitalWrite(fan,HIGH);
          i=90;
          myservo.write(90);
        }
     
        Blynk.virtualWrite(V1,mq2.readSmoke());
        Blynk.virtualWrite(V2,mq2.readSmoke());
    } 
    
    else {
      digitalWrite(Red, LOW);
      digitalWrite(Buzzer, LOW);
      digitalWrite(Green, LOW);
      digitalWrite(fan,LOW);
      for(;i>=0;i--)
      {
        myservo.write(i);
        delay( 50);
      }
      i=0;
    }
  
  
  
  
  
    
    
   
 
}




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

Please edit your post, and add triple backticks ``` before and after your whole sketch.

done

It would be really useful if you clarified if these are physical buttons or widgets, and explained which physical or virtual pins these buttons are connected to.

Pete.

Nevermind I have found the solution.

You should probably read this, to avoid maxing-out the event limits…

Pete.