Difference between revisions of "Arduino 15 - tripple-click"
m |
|||
(One intermediate revision by the same user not shown) | |||
Line 16: | Line 16: | ||
pocet++; | pocet++; | ||
hodnota = digitalRead(4); | hodnota = digitalRead(4); | ||
− | delay( | + | delay(20); |
} | } | ||
} | } | ||
− | return pocet / 2; | + | return (pocet + 1)/ 2; |
} | } | ||
Latest revision as of 12:34, 6 August 2019
void setup() {
pinMode(4, INPUT);
Serial.begin(9600);
}
int dotyk()
{
while (digitalRead(4) == 0) { }
long neskoro = millis() + 500;
int pocet = 0;
int hodnota = digitalRead(4);
while (millis() < neskoro) {
if (digitalRead(4) != hodnota)
{
pocet++;
hodnota = digitalRead(4);
delay(20);
}
}
return (pocet + 1)/ 2;
}
void loop() {
Serial.println(dotyk());
}