#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPL6rU0Z9xc_"
#define BLYNK_TEMPLATE_NAME "tes iot"
#define BLYNK_AUTH_TOKEN "pVtTXKsRb8zaFmlkca6pPzJZsZRKF0lq"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <ESP32Servo.h>
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
Servo servo;
const int led = 21;
int servoVal;
BLYNK_WRITE(V0){
if(param.asInt()==1){
digitalWrite(led, HIGH);
}
else{
digitalWrite(led, LOW);
}
}
BLYNK_WRITE(V1){
servoVal = analogRead(param.asInt());
servoVal = map(servoVal,0,4096,0,180);
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
pinMode(led, OUTPUT);
servo.attach(2);
}
void loop()
{
Blynk.run();
servo.write(servoVal);
}