#include <Arduino.h>
#define PIR_SIGNAL_PIN 0 // Digital pin for motion detection
#define PIR_ADC_MONITOR A4 // ADC pin to monitor VCC voltage
#define THRESHOLD_VCC 1000 // ADC threshold for VCC disconnection (adjust as needed)
void setup() {
pinMode(PIR_SIGNAL_PIN, INPUT); // PIR output pin
Serial.begin(115200);
}
void loop() {
// Read PIR motion detection signal
int pirState = digitalRead(PIR_SIGNAL_PIN);
// Read PIR VCC voltage level
int vccValue = analogRead(PIR_ADC_MONITOR);
// Check if VCC is disconnected
if (vccValue < THRESHOLD_VCC) {
Serial.println("⚠️ PIR VCC Wire Disconnected!");
}
// Check PIR motion detection
else if (pirState == HIGH) {
Serial.println("🚶 Motion Detected!");
}
else {
Serial.println("🛑 No Motion");
}
delay(500);
}