Arduino 15 - tripple-click

From DT^2
Revision as of 14:26, 6 August 2019 by Palo (talk | contribs) (Created page with "<syntaxhighlight lang="C++"> void setup() { pinMode(4, INPUT); Serial.begin(9600); } int dotyk() { long neskoro = millis() + 500; int pocet = 0; int hodnota = digit...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
void setup() {
  pinMode(4, INPUT);
  Serial.begin(9600);
}

int dotyk()
{
  long neskoro = millis() + 500;
  int pocet = 0;
  int hodnota = digitalRead(4);
  while (millis() < neskoro) {
    if (digitalRead(4) != hodnota)
    {
      pocet++;
      hodnota = digitalRead(4);
      delay(50); 
    }
  }
  return pocet / 2;
}

void loop() {
  Serial.println(dotyk());
}