#include "TimerEvent.h"
const int pirPin = 2;
const int buzzerPin = 8;
TimerEvent timer;
void setup() {
pinMode(pirPin, INPUT);
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
timer.set(5000, checkMotion);
}
void loop() {
timer.update();
}
void checkMotion() {
if (digitalRead(pirPin) == HIGH) {
Serial.println("Motion detected!");
digitalWrite(buzzerPin, HIGH);
delay(5000);
digitalWrite(buzzerPin, LOW);
}}