#define BLYNK_TEMPLATE_ID "TMPL6AEwXgNwP"
#define BLYNK_TEMPLATE_NAME "kontrol relay"
#define BLYNK_AUTH_TOKEN "sTneI_nuJW3LMEDORxx7c79hg5pZovEY"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char auth[] = "sTneI_nuJW3LMEDORxx7c79hg5pZovEY";
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
int SW_relay = 0;
BlynkTimer timer;
#define relay 4
#define Buzzer 19
BLYNK_WRITE(V0) {
SW_relay = param.asInt();
if (SW_relay == 1){
digitalWrite(4, HIGH);
Blynk.virtualWrite(V0, HIGH);
}else{
digitalWrite(4, LOW);
Blynk.virtualWrite(V0, LOW);
}
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(4, OUTPUT);
pinMode(19, OUTPUT);
Blynk.begin(auth, ssid, pass);
timer.setInterval(1000L, []() {
});
Serial.println("Setup Selesai");
}
void loop() {
Blynk.run();
timer.run();
//kontrol buzzer
tone(19, HIGH);
delay(1000);
tone(19, LOW);
delay(1000);
}