/* Fill-in information from Blynk Device Info here */
#define BLYNK_TEMPLATE_ID "TMPL2AxHcYKOF"
#define BLYNK_TEMPLATE_NAME "Uche Project Motion Sensor"
#define BLYNK_AUTH_TOKEN "6YoQh2OVob9ikgp1MzLEcB_gqVjDSImr"
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
int pirPin1 = 15; // GPIO for PIR sensor 1
int ledPin1 = 2; // Optional LED for Room 1
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
void setup() {
pinMode(pirPin1, INPUT);
pinMode(ledPin1, OUTPUT);
// Debug console
Serial.begin(115200);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
// You can also specify server:
//Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
}
void loop() {
Blynk.run();
int motionDetected = digitalRead(pirPin1);
if (motionDetected) {
Serial.println("Motion detected!");
digitalWrite(ledPin1, HIGH);
} else {
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
delay(100); // Small delay to avoid bouncing issues
}