#include <Servo.h>
Servo myServo;
int pirPin = 2;
void setup() {
myservo.attach(9);
Serial.begin(9600);
}
void loop() {
myServo.write(0);
int pirValue = digitalRead(pirPin);
Serial.print(pirValue);
if (pirValue == 1) {
myServo.write(90);
delay(1000);
}
}
Copyright ⓒ TECH79 All right reserved