#define BLYNK_TEMPLATE_ID "TMPL2fIpP0lX4"
#define BLYNK_TEMPLATE_NAME "Smart Home"
#define BLYNK_AUTH_TOKEN "0nkgbZPZIzJtLSe4uMAXi3C7L10c1aEz"
// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial
/*
#define BLYNK_TEMPLATE_ID "TMPL33izlgtw1"
#define BLYNK_TEMPLATE_NAME "my temp"
#define BLYNK_AUTH_TOKEN "g9SvnZAOXLljXq1L6KEdoY3wjDzi8LgS"
*/
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <ESP32Servo.h>
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
Servo servo;
// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin V1
BLYNK_WRITE(V0) { // Utilisez V1 pour le slider
int pos = param.asInt(); // Récupérez la valeur du slider
servo.write(pos); // Déplacez le servo à la position spécifiée
}
BLYNK_WRITE(V2) {
if (param.asInt() == 1) { // Vérifie si le bouton est en position ON
tone(15, 262,500); // Joue la note 262Hz
} else {
noTone(15); // Arrête le son si le bouton est désactivé
}
}
BLYNK_WRITE(V1)
{
if(param.asInt()==1){
digitalWrite(25, HIGH);
}
else{
digitalWrite(25, LOW);
} // assigning incoming value from pin V1 to a variable
// process received value
}
void setup()
{
// Debug console
Serial.begin(115200);
servo.attach(18, 500, 2400);
Blynk.begin(auth, ssid, pass);
pinMode(25, OUTPUT);
pinMode(15, OUTPUT);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
}
void loop()
{
Blynk.run();
}