Re: Arduino - Om en kombination händer inom 2 sek
Postat: 9 januari 2019, 12:28:23
Svenskt forum för elektroniksnack.
https://elektronikforumet.com/forum/
Kod: Markera allt
]if (timeElapsed > interval)
{
ledState = !ledState; // toggle the state from HIGH to LOW to HIGH to LOW ...
digitalWrite(led, ledState);
timeElapsed = 0; // reset the counter to 0 so the counting starts over...
}
Kod: Markera allt
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
}