If-Statement only runs once

Hi there!
I’m just getting the hang of Blynk and after getting a connection I’m trying to do some basics with the button widget.
The button writes its state to V0 which is then printed to the serial monitor.
The if statement that follows only works once, to turn the LED off.
Any button presses that follow just print to the serial monitor, but the LED stays off.
After tinkering with it for a while I’ve run out of ideas what the problem could be.

I’d be grateful for any tips!

BLYNK_WRITE(V0) // Button Widget writes to Virtual Pin V0 
{
  int pinValue = 0;
  pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  Serial.print("V0 Button value is: ");
  Serial.println(pinValue);
  
  if (pinValue = 1){
    turnLEDon();
  }
  else {
    turnLEDoff();
  }
}

This should be:

if (pinValue == 1)

One equals sign sets the value, two compare the value. In this case you need to do a comparison.

There may be other issues in the erst of your code, as I would have expected this to turn your LED on each time, not off.

Pete.

Thanks Pete!
This did the trick, however I’m confused as to why the LED is on when the Button state is 0.
This is the entirety of the code:

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "";
char ssid[] = "";
char pass[] = "";


BLYNK_WRITE(V0) // Button Widget writes to Virtual Pin V0 
{
  int pinValue = 0;
  pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  Serial.print("V0 Button value is: ");
  Serial.println(pinValue);
  
  if (pinValue == 1){
    turnLEDon();
  }
  else {
    turnLEDoff();
  }
}

void turnLEDon() {
  digitalWrite(LED_BUILTIN, HIGH);
}

void turnLEDoff() {
  digitalWrite(LED_BUILTIN, LOW);
}


void setup()
{
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);
}
void loop()
{
  Blynk.run();
}

The built-in LED on a NodeMCU is Active LOW - in other words it is On when a LOW signal is applied and Off when a HIGH signal is applied.

Pete.