#define BLYNK_TEMPLATE_ID "TMPL3RuNw8mJd"
#define BLYNK_TEMPLATE_NAME "QUADCOPTER"
#define BLYNK_AUTH_TOKEN "QhcZyPf9JBi56nFJ21rDrvBlRgwqwAoi"
#include <ESP32Servo.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
BlynkTimer timer;
class ServoMotor {
private:
Servo servo;
int pin;
public:
ServoMotor(int servoPin) : pin(servoPin) {
servo.attach(pin);
}
void setPosition(int angle) {
servo.write(angle);
}
};
ServoMotor servo1(4);
const int button1Pin = 26;
int button1State = 0;
void setup() {
pinMode(button1Pin, INPUT);
Blynk.begin(auth, ssid, pass);
}
BLYNK_WRITE(V0) {
int value = param.asInt();
int step=5;
if (value == 1) {
for (int angle = 0; angle <= 180; angle += step) {
Blynk.virtualWrite(V0,angle);
}
}
}
void loop() {
Blynk.run();
button1State = digitalRead(button1Pin);
if (button1State == HIGH) {
Blynk.virtualWrite(V0, 1);
}
}