Try this out
#define interruptPin 2 // pulse Counter input
#define ActivateRelay 3 // interrupt pin to trigger relay on
#define Relay 4 // attach your relay to pin 4
volatile int Counter;
void setup() {
// put your setup code here, to run once:
attachInterrupt(digitalPinToInterrupt(interruptPin), []() { Counter++; }, FALLING);
attachInterrupt(digitalPinToInterrupt(ActivateRelay), []() { digitalWrite(Relay, HIGH); }, RISING);
Counter = 0;
}
void loop() {
// put your main code here, to run repeatedly:
if (Counter = 100) {
digitalWrite(Relay, LOW);
}
}
it uses interrupts to captures start request and pulse count.
Z