Author Topic: Wemos D1_R1 Relay switch Blynk 2.0  (Read 150 times)

0 Members and 1 Guest are viewing this topic.

branx86

  • Administrator
  • Sr. Member
  • *****
  • Posts: 259
  • Karma: +0/-0
    • View Profile
    • cBrandon
Wemos D1_R1 Relay switch Blynk 2.0
« on: May 22, 2022, 08:22:21 AM »


//Brandon Relay controller on WeMos GPIO pin D9 on Blynk 2.0
// Fill-in information from your Blynk Template here
#define BLYNK_TEMPLATE_ID "TMPLPHrQlpSL" //Change to match yours in Blynk 2
#define BLYNK_DEVICE_NAME "RelayONOFF" //Chnage to match yours in Blynk 2

#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG

#define APP_DEBUG

#include "BlynkEdgent.h"

BLYNK_WRITE(V0) //This is set in the Blynk app
{
  if(param.asInt ()==0) {  //Change 0 to 1 if you want to change button state
   digitalWrite(2, HIGH);  //WeMos GPIO D9
    }
  else{
    digitalWrite(2, LOW); //WeMos GPIO D9
  }
}
BLYNK_CONNECTED()
{
  Blynk.syncVirtual(V0); //This is set in the Blynk app
}
void setup()
{
  pinMode (2, OUTPUT); //WeMos GPIO D9
  Serial.begin(115200);
  delay(100);

  BlynkEdgent.begin();
}

void loop() {
  BlynkEdgent.run();
}
« Last Edit: May 30, 2022, 12:57:47 PM by branx86 »