#define BLYNK_TEMPLATE_ID "TMPL34Z9FS_b3"
#define BLYNK_TEMPLATE_NAME "DEVICE CONTROL"
#define BLYNK_AUTH_TOKEN "N0Xly4pvZ6yY02jrTSXGBUUOgUVtvaUo"
//**********BLYNK, library**************************************
#include <BlynkSimpleEsp32.h>
//**********BLYNK, ssid, pass, token****************************
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
//**********LED, pin yg digunakan*******************************
#define pin1LED 15
#define pin2LED 2
#define pin3LED 4
#define pin4LED 5
//**********BLYNK, mendapat input dr blynk lewat datastream V0**
BLYNK_WRITE(V0)
{
int saklar1=param.asInt();
digitalWrite(pin1LED, saklar1);
}
BLYNK_WRITE(V1)
{
int saklar2=param.asInt();
digitalWrite(pin2LED, saklar2);
}
BLYNK_WRITE(V2)
{
int saklar3=param.asInt();
digitalWrite(pin3LED, saklar3);
}
BLYNK_WRITE(V3)
{
int saklar4=param.asInt();
digitalWrite(pin4LED, saklar4);
}
//*********BLYNK, syncron data terakhir saat koneksi tersambung*
BLYNK_CONNECTED() {
Blynk.syncAll();
}
void setup() {
//********LED, setting pin jadi output************************
pinMode(pin1LED, OUTPUT);
pinMode(pin2LED, OUTPUT);
pinMode(pin3LED, OUTPUT);
pinMode(pin4LED, OUTPUT);
//********BLYNK, mulai koneksi ke blynk***********************
Blynk.begin(auth, ssid, pass);
}
void loop() {
//********BLYNK, menjalankan blynk****************************
Blynk.run();
}