const char *Version = "260829a";
const int PinBut = 4;
unsigned long msec;
int cnt;
int cnt2;
char s [90];
// -----------------------------------------------------------------------------
const unsigned long DebounceMsec = 30;
unsigned long butMsec = 0;
byte butState;
void butChk ()
{
int but = digitalRead (PinBut);
if (butState != but) {
butState = but;
cnt++;
if (msec - butMsec > DebounceMsec) {
butMsec = msec;
if (but == LOW) {
sprintf (s, " %6d %6d", cnt, ++cnt2);
Serial.println (s);
}
}
}
}
// -----------------------------------------------------------------------------
void loop ()
{
msec = millis ();
butChk ();
}
// -----------------------------------------------------------------------------
void setup ()
{
Serial.begin (115200);
Serial.println (Version);
pinMode (PinBut, INPUT_PULLUP);
}