#define BLYNK_TEMPLATE_ID "TMPL37UJ-mnfB"
#define BLYNK_TEMPLATE_NAME "servo moter eltra sonic sencer"
#define BLYNK_AUTH_TOKEN "Y48boce2h3vbC1he6a95-rd88V2GFIAU"
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <Servo.h>
#include <NewPing.h>
// WiFi parameters
const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";
// Blynk auth token
char auth[] = "your_AUTH_TOKEN";
// Ultrasonic sensor parameters
#define TRIGGER_PIN 13
#define ECHO_PIN 12
#define MAX_DISTANCE 200
// Servo motor parameters
#define SERVO_PIN 14
Servo servo;
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
BLYNK_WRITE(V0) {
int value = param.asInt();
servo.write(value);
}
void setup() {
Serial.begin(115200);
Blynk.begin(auth, ssid, password);
servo.attach(SERVO_PIN);
}
void loop() {
int distance = sonar.ping_cm();
Blynk.virtualWrite(V1, distance);
delay(100);
}
//write a code in esp32 to control servo motor with the help of blynk console website there is slider in dashboard which is a virtual pin v0 for slider and when in the blynk dashboard the slider is slided to 50 or 60 then in wokwi the servo motor will be rotated to 50 and 60 degree simuntaneously and v1 is a virtual pin for gauge in blynk dashboard it will connected to ultrasonic to show the cm in wokwi