(https://i.ibb.co/LzpcdBy/WEMOS-D1-R1-Pinout.jpg) (https://ibb.co/LzpcdBy)
//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();
}