Arduino has a convenient function called pulseIn that you can use to count the HIGH or the LOW of a pulse. To test this, I created a square wave using the excellent Circuit Gear Waveform Generator.
I uploaded this program and connected the output of the waveform generator to the board (connect the Red wire to the Arduino pin 3, and the black to the Arduino digital ground). The program started printing the count of the HIGH pulses. As I adjusted the frequency of the square ware, the print out was getting faster or slower depending on the frequency of the wave. But as I started changing the amplitude of the square wave, I noticed than when the voltage difference between the LOW and HIGH of the square wave was less than 4 volts, the pulseIn function could no longer read the HIGHs. The documentation for the HIGH confirmed that the difference between the LOW and HIGH must be at least greater than 3 volts. In my case, anything less than 4 volts just didn’t work.
To show a waveform on the Circuit Gear, connect the output of the generator (leftmost connector) to one of the oscilloscope inputs (the two on the right). You’ll need something that can connect to BNC connectors, either alligator clip leads or adaptors or scope probes.
In other words, there is no internal connection between the output of the generator and the input of the oscilloscope, you have to add that.
(If you had another oscilloscope, you could also connect the output of the generator to that oscilloscope and view the waveform.)
Here is the pulse counter program for the Arduino:
int pulsePin = 3;
unsigned long counter = 0;
unsigned long duration = 0;
unsigned long timeout = 1000000; // in microseconds
void setup() {
pinMode(pulsePin, INPUT);
// enable the 20K pull-up resistor to steer
// the input pin to a HIGH reading.
digitalWrite(pulsePin, HIGH);
Serial.begin(9600);
Serial.println("Here we go again");
}
void loop() {
duration = pulseIn(pulsePin, HIGH, timeout);
if (duration == 0) {
Serial.print("Pulse started before the timeout.");
Serial.println("");
} else {
counter++;
Serial.print(counter);
Serial.print(", ");
Serial.print(duration);
Serial.println("");
}
}


