const int pulsePin = 2; // Pin where pulses are received
volatile unsigned long pulseCount = 0;
void setup() {
pinMode(pulsePin, INPUT);
attachInterrupt(digitalPinToInterrupt(pulsePin), countPulse, RISING); // Count on rising edge
Serial.begin(9600);
}
void loop() {
// Print the pulse count every second
Serial.print("Pulse Count: ");
Serial.println(pulseCount);
delay(1000);
}
void countPulse() {
pulseCount++;
}