#include <Servo.h>
Servo servoIn;
Servo servoOut;
int btnIn = 2;
int btnOut = 3;
int pirIn = 4;
int pirOut = 7;
void setup() {
servoIn.attach(5);
servoOut.attach(6);
pinMode(btnIn, INPUT_PULLUP);
pinMode(btnOut, INPUT_PULLUP);
pinMode(pirIn, INPUT);
pinMode(pirOut, INPUT);
Serial.begin(9600);
}
void loop() {
// ===== ENTREE =====
if (digitalRead(btnIn) == LOW || digitalRead(pirIn) == HIGH) {
servoIn.write(90);
delay(2000);
servoIn.write(0);
}
// ===== SORTIE =====
if (digitalRead(btnOut) == LOW || digitalRead(pirOut) == HIGH) {
servoOut.write(90);
delay(2000);
servoOut.write(0);
}
}