Difference between revisions of "Arduino 15 - tripple-click"
Line 19: | Line 19: | ||
} | } | ||
} | } | ||
− | 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());
}