#include <Servo.h>
#define BLYNK_TEMPLATE_ID "TMPLGLkqPzJO"
#define BLYNK_DEVICE_NAME "Smart Jemuran"
#define BLYNK_AUTH_TOKEN "vlCutVlowAr6fG7p7qqGW62I2Hq8YYP-"
#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, hujan;
Servo jemuran;
bool status = false;
BLYNK_WRITE(V0)
{
int pinValue = parm.asInt();
if (pinValue ==1){
status = true;
}
else{
status = false;
}
}
void setup() {
Serial.begin(115200);
jemuran.attach(25);
Blynk.begin(auth, ssid, pass);
}
void loop() {
Blynk.run();
ldr =map(analogRead(34), 0, 4096, 100,0);
hujan =map(analogRead(35),0, 4096, 0,100);
if (status == true){
jemuran.write(0);
}else{
if (ldr <20 || hujan >35){
jemuran.write(180);
Serial.println("jemuran Tutup");
}
}
}