#define BLYNK_TEMPLATE_ID "TMPL6seXzB38B"
#define BLYNK_TEMPLATE_NAME "SmartHome"
#define BLYNK_AUTH_TOKEN "qsO1bOkmQSix-S-Avr628_yZ63J-aMix"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#define pirPin 14
#define ledPin 12
int statusPir = LOW;
int bacaPin;
BlynkTimer timer;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = BLYNK_AUTH_TOKEN;
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Wokwi-GUEST"; //nama hotspot yang digunakan
char pass[] = ""; //password hotspot yang digunakan
void motiondetect(){
if(digitalRead(pirPin)==HIGH){
Blynk.virtualWrite(V0,1);
Serial.println("Motion detected!");
digitalWrite(ledPin, HIGH);
}
else{
Blynk.virtualWrite(V0,0);
Serial.println("Motion ended!");
digitalWrite(ledPin, LOW);
}
}
void setup()
{
// Debug console
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
pinMode(pirPin, INPUT);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
}
void loop(){
Blynk.run();
}