#define PULSE_IN 9
#define PULSE_OUT 4
#define PULSE_TIME 1000
#define IDLE_TIME 5
int pulseDelay = 0;
void setup() {
Serial.begin(115200);
pinMode(PULSE_IN, INPUT_PULLUP);
pinMode(PULSE_OUT,OUTPUT);
digitalWrite(PULSE_OUT,LOW);
}
void loop() {
if(digitalRead(PULSE_IN) == 0){
Serial.println("Pulse Detected");
digitalWrite(PULSE_OUT,HIGH);
delay(PULSE_TIME);
digitalWrite(PULSE_OUT,LOW);
Serial.println("Idle Mode");
for(pulseDelay = IDLE_TIME; pulseDelay >=0;pulseDelay--){
Serial.println(pulseDelay);
delay(1000);
}
Serial.println("Ready for New pulse");
}
}