long ms;
bool press;
long num;
void setup() {
// put your setup code here, to run once:
pinMode(A0, INPUT_PULLUP);
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
if (!analogRead(A0))
{
ms = millis() + 100;
while (!analogRead(A0))
{
if (ms <= millis())
{
press = true;
}
else
{
press = false;
}
}
}
if (press)
{
num++;
Serial.println(num);
}
}