BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

A problem that I can't find an explanation for blynk 2.0

Hello my friends
Please help on Blynk 2.0
Simple code to turn on a default LED but I don’t know why it gives me the value ON in both cases when I press the control button

// Fill-in information from your Blynk Template here
#define BLYNK_TEMPLATE_ID "TMPLJqpRzTuD"
#define BLYNK_DEVICE_NAME "ULTRA 1"

#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG

#define APP_DEBUG

// Uncomment your board, or configure a custom board in Settings.h
//#define USE_SPARKFUN_BLYNK_BOARD
//#define USE_NODE_MCU_BOARD
//#define USE_WITTY_CLOUD_BOARD


#include "BlynkEdgent.h"

const int Relay1  = D1;
#define vPIN_LedRelay1        V1
WidgetLED LedRelay1(vPIN_LedRelay1);

BLYNK_WRITE(V2)
{
  if (param.asInt() == 0)
  {
    digitalWrite(Relay1, HIGH);
    LedRelay1.off();
    Serial.println("OFF");
     
  }
  else
  {
    digitalWrite(Relay1, LOW);
    LedRelay1.on();
    Serial.println("ON");
  }
}


void setup()
{
  Serial.begin(115200);
  delay(100);

  BlynkEdgent.begin();
  pinMode(Relay1, OUTPUT);
  digitalWrite(Relay1, HIGH);
}

void loop() {
  BlynkEdgent.run();
}

7 Uploading: 7.PNG…

@PeteKnight
My friend Pete, can I ask you for help

@Dmitriy

@Blynk_Coeur

What’s your problem :thinking:

1 Like

Thank you, my friend,@Blynk_Coeur for the response. I made a blynk write to run a virtual LED and also Riley on D1, but there is no real response. Look at the code. There is no problem

1 Like

It only turns on the LED and does not stop it. I already used this method in blynk v1 and didn’t face any problem

1 Like

Some information about how you’ve configured your datastream would be useful.

Pete.

2 Likes

Thank you my friend, can you explain more?

You will have created a template in the web dashboard and defined datastream(s).
You need to share details of that datastream setup.

Pete.

1 Like

Thank you my friend, the problem is solved