#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
// Your Wi-Fi credentials
// you have to change only token id
char auth[] = "2iIx7W-lgEXMdpowlI-3ZgXKPZBziBL7";
// if you are using Wokwi Simulator then no need to change SSID and Pass you can directly copy and past it.
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
// Pin connected to the LED
int ledPin = 2;
void setup() {
Serial.begin(115200);
// Connect to Wi-Fi
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connecting to WiFi...");
// Connect to Blynk
Blynk.begin(auth, ssid, pass);
pinMode(ledPin, OUTPUT);
}
//Blynk virtual pin handler for LED Control
BLYNK_WRITE(V0){
int ledState = param.asInt();
if (ledState == 1) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}
void loop(){
Blynk.run();
}