Ask about button on blynk app with relay

want to ask, if i want to make a button on the blynk app with that code, but it can not work. thanks for the answer

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define RELAY1 D3
#define RELAY2 D4
char auth[] = "";
char ssid[] = "";
char pass[] = "";
int kondisitombol;

void setup() 
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  pinMode(D3, OUTPUT);
  pinMode(D4, OUTPUT);
  digitalWrite(RELAY1,HIGH);
  digitalWrite(RELAY2,HIGH);
}

BLYNK_WRITE(V2)
{
  if(param.asInt())
  {
    kondisitombol=1;
  }
  else
  {
    kondisitombol=0;
  }
}

void loop() 
{
  if(kondisitombol==1)
  {
    digitalWrite(RELAY1,LOW);
    delay(3000);
  }
  else
  {
    digitalWrite(RELAY2,HIGH);
    delay(2000);
  }
 Blynk.run();
}

First you need to learn some Blynk basics like NO delays and keep the void loop() as clear as possible

etc…

1 Like

okey, thanks for the answer