/*
https://electronics.stackexchange.com/questions/464324/counting-pulses-using-arduino-uno
I am trying to count pulses from a waveform generator using an Arduino Uno. The waveform generator is set at the following settings:
Waveform Type: Pulse
Freq: 20 Hz (50ms)
Amplitude: 3.0 Vpp
Offset: 0V
Width = 5ms
So far I get only 0s displayed on my serial monitor.
Here is what I have tried so far:
1) Using pulseIn() and pulseInLong() --> no success
2) Check wiring connections --> Used multimeter to check and they are properly connected.
3) Hookup an oscilloscope to see if the waveform is being generated --> The waveform is being generated as shown in pictures below.
Note: The waveform generator is part of the oscilloscope:
Waveform Generator
Connection Diagram
My code is shown below:*/
volatile int IRQcount;
int pin = 14;
int pin_irq = 14; //IRQ that matches to pin 2
int result = 0;
bool T=false;
void setup() {
// put your setup code here, to run once:
Serial.begin (115200);
pinMode(14, INPUT_PULLUP);
attachInterrupt(pin_irq, IRQcounter, FALLING);
}
void IRQcounter() {
IRQcount++;
T=true;
}
void loop() {
If(T){
Serial.print("Counted = ");
Serial.println(IRQcount);
T=false;
}
}