unsigned volatile long pulse = 0;
unsigned long new_pulse = 0;
#define reset 12
void count()
{
pulse = pulse + 1;
digitalWrite(13, HIGH);
}
void setup()
{
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(2, INPUT_PULLUP); //0 interrupt channel number input from GM tube pulse GPIO2 \_
pinMode(12, INPUT_PULLUP);
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
attachInterrupt(digitalPinToInterrupt(3), count, FALLING);
// NVIC_SET_PRIORITY(IRQ_PORTA, 0); // teensy 3.6 https://youtu.be/H3o08WE0zEI
}
void loop()
{
// put your main code here, to run repeatedly:
unsigned long nowpulse = pulse;
if (nowpulse != new_pulse) {
digitalWrite(13, LOW);
Serial.println(nowpulse);
new_pulse = nowpulse;
delay(1);
}
if (digitalRead(reset) == 0)
{
pulse = 0;
}
}