The Response of App is slowing down

Hello Pavel and the Blynk Team,
First of all I Thank you all very much for inventing such a wounderfull system. I was struggling for the last couple of months to come up with similar system.
Finally I got it few days back and today I am ready with my project.
I have few dificulties and few querries also.
First the difficulties I am facing, Below is the Arduino Mega Program and the screen shot of the Blynk app.

 **************************************************************/
//#define BLYNK_DEBUG
#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SimpleTimer.h>


// Set ESP8266 Serial object
#define EspSerial Serial1

ESP8266 wifi(EspSerial);
SimpleTimer timer;

// You should get Auth Token in the Blynk App.

char auth[] = "34ed15e0e2da48398a39c11add71f9ab";

WidgetLED led11(11);
WidgetLED led12(12);
WidgetLED led13(13);
WidgetLED led14(14);
WidgetLED led15(15);
WidgetLED led16(16);
WidgetLED led20(20);    // Running LED
WidgetLED led21(21);     // Test LED connected to 52

int ChkOutputState22 = 0;
int ChkOutputState23 = 0;
int ChkOutputState24 = 0;
int ChkOutputState25 = 0;
int ChkOutputState26 = 0;
int ChkOutputState27 = 0;

void setup()
{
  Serial.begin(115200);     // Set console baud rate
  delay(10);
  EspSerial.begin(115200);  // Set ESP8266 baud rate
  delay(10);

//  Blynk.begin(auth, wifi, "ssid", "pass");
  
  Blynk.begin(auth, wifi, "SANTOSH_BB", "snch2000@");
 //  Blynk.begin(auth, wifi, "MYWIFI", "12345678");

//   Blynk.begin(auth, wifi, "ATC_Bangalore", "atc_bang_991");



// Reset all Arduino outputs to HIGH
pinMode(22, OUTPUT);
pinMode(23, OUTPUT);
pinMode(24, OUTPUT);
pinMode(25, OUTPUT);
pinMode(26, OUTPUT);
pinMode(27, OUTPUT);
digitalWrite(22, HIGH);  // active Low
digitalWrite(23, HIGH);   // active Low
digitalWrite(24, HIGH);  // active Low
digitalWrite(25, HIGH);   // active Low
digitalWrite(26, HIGH);  // active Low
digitalWrite(27, HIGH);   // active Low




  // Make pin 52 default HIGH, and attach INT to our handler
  pinMode(52, INPUT_PULLUP);
  // Attach INT to our handler
 // attachInterrupt(digitalPinToInterrupt(2), checkPin, CHANGE);
   
 while (Blynk.connect() == false) {
    // Wait until connected
  }

  timer.setInterval(200L, blinkLedWidget);
 // timer.setInterval(5000L, LEDLastStatus);

}


  void blinkLedWidget()    // connnected to V20   // "Running" LED
{
  if (led20.getValue()) {
    led20.off();
  } else {
    led20.on();
  }
}


  void LEDLastStatus()    // LED Last status to display the status when Mobile App is started
{

  ChkOutputState22 = digitalRead(22);   // reading  output pin 22
  ChkOutputState23 = digitalRead(23);   // reading  output pin 23
  ChkOutputState24 = digitalRead(24);   // reading  output pin 24
  ChkOutputState25 = digitalRead(25);   // reading  output pin 25
  ChkOutputState26 = digitalRead(26);   // reading  output pin 26
  ChkOutputState27 = digitalRead(27);   // reading  output pin 27
  
  if (ChkOutputState22 == LOW){led11.on();} //else{led11.off();}   // actice low 
  if (ChkOutputState23 == LOW){led12.on();} //else{led12.off();}   // actice low 
  if (ChkOutputState24 == LOW){led13.on();} //else{led13.off();}   // actice low 
  if (ChkOutputState25 == LOW){led14.on();} //else{led14.off();}   // actice low 
  if (ChkOutputState26 == LOW){led15.on();} //else{led15.off();}   // actice low 
  if (ChkOutputState27 == LOW){led16.on();} //else{led16.off();}   // actice low 

}


//int prevState = -1;
//int currState = -1;
int prevState = 1;
int currState = 1;
long lastChangeTime = 0;

void checkPin()
{
  // Invert state, since button is "Active LOW"
  int state = !digitalRead(52);

  // Debounce mechanism
  long t = millis();
  if (state != prevState) {
    lastChangeTime = t;
  }
  if (t - lastChangeTime > 50) {
    if (state != currState) {
      currState = state;
    //  Blynk.virtualWrite(21, state);
    //  BLYNK_LOG("Got a value: %i",state);
      if(state==1){
        led21.on();
      }
      else{
       led21.off(); 
      }
      
    }
  }
  prevState = state;
}

BLYNK_WRITE(1)  // virtual pin1 control on App
{
  if (param.asInt()) {
    digitalWrite(22, LOW);   // control PIN22 of Arduino , Active Low
    led11.on();
  } else {
    digitalWrite(22, HIGH);
    led11.off();
  }
}
BLYNK_WRITE(2)    // virtual pin2 control on App 
{
  if (param.asInt()) {
    digitalWrite(23, LOW);   // control PIN23 of Arduino
    led12.on();
  } else {
    digitalWrite(23, HIGH);
    led12.off();
  }
}
BLYNK_WRITE(3)  // virtual pin3 control on App
{
  if (param.asInt()) {
    digitalWrite(24, LOW);   // control PIN24 of Arduino
    led13.on();
  } else {
    digitalWrite(24, HIGH);
    led13.off();
  }
}
BLYNK_WRITE(4)    // virtual pin4 control on App 
{
  if (param.asInt()) {
    digitalWrite(25, LOW);   // control PIN25 of Arduino
   led14.on();
  } else {
    digitalWrite(25, HIGH);
    led14.off();
  }
}
BLYNK_WRITE(5)  // virtual pin5 control on App
{
  if (param.asInt()) {
    digitalWrite(26, LOW);   // control PIN26 of Arduino
    led15.on();
  } else {
    digitalWrite(26, HIGH);
    led15.off();
  }
}
BLYNK_WRITE(6)    // virtual pin6 control on App 
{
  if (param.asInt()) {
    digitalWrite(27, LOW);   // control PIN27 of Arduino
    led16.on();
  } else {
    digitalWrite(27, HIGH);
    led16.off();
  }
}



void loop()
{
  Blynk.run();
  timer.run();
  checkPin();
  LEDLastStatus();
}

The response of command is detoriating as soon as I add the function LEDLastStatus().
Pl. advise how to write this fuction without afecting the response.

Other querries is to how to make the apk of this app, so that it can be distributed to others.

Regards,
Santosh

@santosh1971

Hi, thank you for your feedback! You need to move “LEDLastStatus” to timer. See this basic example. Also please read carefully comments in this sketch.

Other querries is to how to make the apk of this app, so that it can be distributed to others.

This is not possible at the moment but we are working on it.

I tried the timer way also as you can see, I have commented the same. It was also having the similar problem.

Could you try those sketch with local server? the problems could be in slow ping between Blynk server and your hardware.