#include <mechButton.h>
#include <timeObj.h>
#define DOWNTIME_MS 250 // Time in ms to wait before sending the number.
// 250 works good for this. Trry 39 for yours.
mechButton listener(2);
timeObj lineTimer(DOWNTIME_MS,false);
int count;
void setup() {
count = 0;
Serial.begin(9600);
listener.setCallback(clicked);
}
void clicked(void) {
if (!listener.getState()) { // If we get a high to low..
count++; // Bump up the count.
lineTimer.start(); // Start the timer.
}
}
void loop() {
idle(); // Run the magic.
if (lineTimer.ding()) { // If the timer goes off..
Serial.println(count);
count = 0;
lineTimer.reset();
}
}