#include <Servo.h>
#define PIR_MOTION_SENSOR_PIN 3
#define BUZZER_PIN 5
#define LED_PIN 2
#define SERVO_PIN 10
Servo servo;
void setup() {
pinMode(PIR_MOTION_SENSOR_PIN, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
pinMode(LED_PIN, OUTPUT);
servo.attach(SERVO_PIN);
}
void loop() {
int pirState = digitalRead(PIR_MOTION_SENSOR_PIN);
if (pirState == HIGH) {
digitalWrite(BUZZER_PIN, HIGH);
digitalWrite(LED_PIN, HIGH);
servo.write(180);
delay(86400000);//24ชม.
digitalWrite(BUZZER_PIN, LOW);
digitalWrite(LED_PIN, LOW);
} else {
servo.write(0);
delay(100);
}
}