/**use bkynk switch to turn on the LED**/
//blynk code
#define BLYNK_TEMPLATE_ID "TMPL6Kgj2cRz2"
#define BLYNK_TEMPLATE_NAME "FirstLEDBlink"
#define BLYNK_AUTH_TOKEN "pxuo0RXEpVrV2uHHk5Hgz2W4SX6uctGN"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>//blynk code
// Name of the router and password
const char* ssid = "Wokwi-GUEST";
const char* password = "";
const int led = 12;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(led, OUTPUT);
// Start wifi - 2 parameters (ssid & password)
WiFi.begin(ssid, password);
Serial.println("Connecting to WiFi");
// Connection status
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// Connection Info
Serial.println("");
Serial.println("WiFi connected!");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
// 3 parameters - Token, ssid, password
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, password);
}
// From Blynk to Wowki we need to write the LED status
// to write we always use this method (Blynk method)
BLYNK_WRITE(V0) {
// get the status of the virtual switch V0
int status = param.asInt();
digitalWrite(led, status);
}
void loop() {
Blynk.run();
}