Voici un essai :
bool state1 = false;
bool state2 = false;
unsigned long tempsON1 = 0;
unsigned long tempsON2 = 0;
const int motionPin = 2;
const int soundPin = 4;
int motionState = 0;
int soundState = 0;
const unsigned long attente1 = 10; // minutes
const unsigned long attente2 = 30; // secondes
void setup() {
Serial.begin(115200);
pinMode(motionPin, INPUT);
pinMode(soundPin, INPUT);
}
void loop() {
if (!state1) {
motionState = digitalRead(motionPin);
if (motionState == LOW) {
tempsON1 = millis();
state1 = true;
// lancer la vidéo n°1
Serial.println("vidéo 1");
}
} else {
if (millis() - tempsON1 > attente1 * 60000ul) state1 = false;
if (millis() - tempsON2 > attente2 * 1000ul) state2 = false;
if (!state2) {
soundState = digitalRead(soundPin);
if (soundState == LOW) {
state2 = true;
tempsON2 = millis();
// lancer la vidéo n°2
Serial.println("vidéo 2");
}
}
}
}
J'ai ajouté une temporisation de 30 secondes pour le second capteur afin d'éviter qu'il lance la seconde vidéo de manière répétitive.
A tester...