#include <Servo.h>
#define BLYNK_TEMPLATE_ID "TMPL608a_hhrZ"
#define BLYNK_TEMPLATE_NAME "Pengendalian LED"
#define BLYNK_AUTH_TOKEN "oFMLx1ikqcf0MtIExqvUaw5RnlqOVZrF"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
int ldr, air;
Servo pintu;
bool status = false;
BLYNK_WRITE(V0){
int pinValue = parm.asInt();
if (pinValue==1){
status = true;
}
else{
status = false;
}
}
void setup() {
Serial.begin(115200);
air.attach(21);
Blynk.begin(auth, ssid, pass);
}
void loop() {
Blynk.run();
ldr = map(analogRead(16), 0, 4096, 100, 0);
air = map(analogRead(19), 0, 4096, 0, 100);
if (status==true){
air.write(0);
Serial.println("Air Hidup");
}
else{
if (ldr<20 || air>35){
air.write(180);
Serial.println("Air Mati");
}
}
}