#define BLYNK_TEMPLATE_ID "TMPL3fbS4LbBo"
#define BLYNK_TEMPLATE_NAME "HOME AUTOMATION"
#define BLYNK_AUTH_TOKEN "bfrxjZmU355OV-Q0qcWr-MF0Fu6ttW9H"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
//#include<ESP32Servo.h>
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
#define SERVO_PIN 13 // GPIO pin connected to servo signal wire
#include <ESP32Servo.h>
Servo servo;
bool isServoActive = false;
BLYNK_WRITE(V1) // Virtual Button Widget on V1
{
isServoActive = param.asInt(); // Get value from button
if (isServoActive) {
servo.write(180); // Set servo to 180 degrees
} else {
servo.write(0); // Set servo back to 0 degrees
}
}
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
servo.attach(SERVO_PIN); // Attach servo to GPIO pin
}
void loop()
{
Blynk.run();
}