I can't get the status of my push button on blynk

Hello team im trying to run a motor remotly by connecting an output to the pin 2 everything is working fine but i want a feedback input to let me know that the motor is running i tried to use the pin number 6 with Blynk.virtualWrite function but still cant get any feedback when i simulate the input from 5v of the board and pin number 6




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

/* Fill-in your Template ID (only if using Blynk.Cloud) */
#define BLYNK_TEMPLATE_ID "TMPL6vYPBfgt_"
#define BLYNK_TEMPLATE_NAME "mkr 1400"
#define BLYNK_AUTH_TOKEN "9fhnYlv8hBiintHGuBVrbJKKPc7cqCut"


#include <SPI.h>
#include <MKRGSM.h>
#include <BlynkSimpleMKRGSM.h>

GSMClient client;
GPRS gprs;
GSM gsmAccess;


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

// Your SIM and GPRS credentials
// Leave empty, if missing pin, user or pass
char pin[]  = "";
char apn[]  = "web.vodafone.com.qa";
char user[] = "";
char pass[] = "";


const int BUTTON_VPIN = 6;
int buttonState = digitalRead(BUTTON_VPIN);
BLYNK_WRITE(V1) // Executes when the value of virtual pin 0 changes
{
  if(param.asInt() == 1)
  {
    // execute this code if the switch widget is now ON
    digitalWrite(2,HIGH);  // Set digital pin 2 HIGH
  }
  else
  {
    // execute this code if the switch widget is now OFF
    digitalWrite(2,LOW);  // Set digital pin 2 LOW    
  }
  

 
 
  delay(10);
}
void setup()
{
 
  
  
  pinMode(2, OUTPUT); // Initialise digital pin 2 as an output pin



  Serial.begin(9600);

  Blynk.begin(auth, gsmAccess, gprs, client, pin, apn, user, pass);
}

void loop()
{
  Blynk.run();
   Blynk.virtualWrite(V6, buttonState);
}

@keirone

First things first, you MUST REMOVE THIS FROM YOUR VOID LOOP…

Having it in there is flooding the Blynk server with thousands of messages per second.

Pete.

This piece of code executes only once, when the device boots, and it probably won’t read the value of pin GPIO6, as that GPIO isn’t declared as an INPUT in a pinMode statement, and even if it were then that declaration comes later in the code execution sequence.

I’m a bit confused why you’ve use the name BUTTON_VPIN for this, as that implies it’s a virtual pin rather than a GPIO on your board that you’re reading.
Do you realise that there is no connection whatsoever between the virtual pins/datastreams in Blynk and the physical pins on your board?

If you want to read a GPIO pin on a regular basis (lets say once every second) and update a Blynk virtual datastream with the result then you need to use BlynkTimer to call a function once per second.
That function should read your GPIO pin, and write the result to a Blynk virtual datastream.

You seem to be using a switch widget for this “motor running” indicator, but I would have thought than an LED widget would have made more sense.

Pete.