Button Feed back?

Hello all.

Very new to Blynk and a bit of a noob in Arduino overall but have gotten this far!

Issue i am having is that sometimes pressing the button in the app doesn’t activate the virtual pin.

Is there some sort of feedback that can be added to the button so if the command doesn’t work it doesn’t change status?

Have updated code to run digital reads less often.

Appears to have helped but still missing app commands on occasion.

  /*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************
  Note: This only works on Android!
        iOS does not support Bluetooth 2.0 Serial Port Profile
        You may need to pair the module with your smartphone
        via Bluetooth settings. Default pairing password is 1234

  Feel free to apply it to any other example. It's simple!

  NOTE: Bluetooth support is in beta!

  This example shows how to send values to the Blynk App,
  when there is a widget, attached to the Virtual Pin and it
  is set to some frequency

  Project setup in the app:
    Value Display widget attached to V5. Set any reading
    frequency (i.e. 1 second)
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11); // RX, TX

#include <BlynkSimpleSerialBLE.h>
#include <SoftwareSerial.h>

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

BlynkTimer timer; // Announcing the timer

SoftwareSerial SerialBLE(10, 11); // RX, TX


//Assign inputs to wanted Arduino pins here

const int VVTpin = 7;
const int FPin = 8;

//Assign outputs to wanted Arduino pins here
const int mainrelay = 2;
const int starter = 3;
const int FPout = 4;
const int headlight = 5;

//initialise input state

unsigned long previousMillis = 0;
unsigned long onPauseMillis = 0;
unsigned long currentMillis;
int starterrelaystate = 0;
int mainrelaystate = 0;
int headlightstate = 0;
int pause = 0;



//setup timer for starter to be ran before cancel

const unsigned long OnTime = 5000;
const unsigned long PauseTime = 2000;

void engineon()
{ //Engine on command from App:
  mainrelaystate = HIGH;
  digitalWrite(mainrelay, mainrelaystate);
  onPauseMillis = currentMillis;
  pause = HIGH;
}

void engineoff()
{ //Engine off command from App:
  pause = LOW;
  mainrelaystate = LOW;
  digitalWrite(mainrelay, LOW);
  digitalWrite(starter, LOW);
  digitalWrite(headlight, LOW);
  digitalWrite(FPout, LOW);
  mainrelaystate = LOW;

}

// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin 1

BLYNK_WRITE(V1)
{
  int pinValue = param.asInt();
  Serial.print("V1 Slider value is: ");
  Serial.println(pinValue);
  if (pinValue == 1)     // if Button sends 1
    engineon();
  else
    engineoff();// start the function
}



void enginestart()
{ //Engage starter motor:
  pause = LOW;
  starterrelaystate = HIGH;
  digitalWrite(starter, starterrelaystate);
  previousMillis = currentMillis;
}

void killstarter()
{ //Kill Starter function
  pause = LOW;
  starterrelaystate = LOW;
  digitalWrite(starter, starterrelaystate);
}

void headlighton()
{ digitalWrite(headlight, HIGH);
}
void readInputs()
{
//Kill starter motor once engine running:
  if ((digitalRead(VVTpin) == LOW) && (mainrelaystate == HIGH))
  {
    killstarter();
  }
//Starter Motor control:
  currentMillis = millis(); // Remember the current time and turn off starter after timer complete:
  if (((starterrelaystate) == HIGH) && (currentMillis - previousMillis >= OnTime))
    killstarter();


  //Pause on power up before engaging starter motor
  if (((pause) == HIGH) && (currentMillis - onPauseMillis >= PauseTime) && (mainrelaystate == HIGH))
    enginestart();

  

  //Fuelpump relay control:
  if ((digitalRead(FPin) == LOW) && (mainrelaystate == HIGH))
  {
    digitalWrite(FPout, HIGH);
  }
  else
  {
    digitalWrite(FPout, LOW);
  }

  //Headlight control:
  if ((digitalRead(FPin) == LOW) && (digitalRead(VVTpin) == LOW) && (mainrelaystate) == HIGH)
    headlighton();


}

void setup()
{
    timer.setInterval(250L, readInputs);    //timer will run every sec 
  // Debug console
  Serial.begin(9600);

  SerialBLE.begin(115200);
  Blynk.begin(SerialBLE, auth);

  Serial.println("Waiting for connections...");

  /*Set Assigned pins to be either an input or an output*/
  pinMode(VVTpin, INPUT_PULLUP);
  pinMode(FPin, INPUT_PULLUP);

  pinMode(mainrelay, OUTPUT);
  pinMode(starter, OUTPUT);
  pinMode(FPout, OUTPUT);
  pinMode(headlight, OUTPUT);

  
  

}

void loop()
{
  

  Blynk.run();
  timer.run();        // run timer every second
}


Not sure if I understood your problem, but you can set the Virtual Button as a Switch, and down the line on your code you can “reset” the Virtual Button to it’s iddle status.