#define BLYNK_TEMPLATE_ID "TMPL6ILnRQVzp"
#define BLYNK_TEMPLATE_NAME "KONTROL LAMPU 1"
#define BLYNK_AUTH_TOKEN "mBQDt5Smd_-lp9ZcoaeLRvEL6pj2Y712"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char auth[] = "mBQDt5Smd_-lp9ZcoaeLRvEL6pj2Y712";
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
BlynkTimer timer;
#define LED 18
int SW_state = 0;
BLYNK_WRITE (V0)
{
SW_state = param.asInt();
if(SW_state == 1){
digitalWrite(LED, HIGH);
Serial.println("Lampu telah hidup");
Blynk.virtualWrite(V0, HIGH);
}else{
digitalWrite(LED, LOW);
Serial.println("Lampu telah mati");
Blynk.virtualWrite(V0, LOW);
}
}
void setup() {
Serial.begin(115200);
pinMode(LED, OUTPUT);
Blynk.begin(auth, ssid, pass);
}
void loop() {
Blynk.run();
timer.run();
}