Created
April 5, 2016 13:26
-
-
Save rafalw/5927cf10d0d98d305af41b04aa580741 to your computer and use it in GitHub Desktop.
Alternatywa dla delay() - bez użycia bibliotek typu Timer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
pinMode(13, OUTPUT); | |
digitalWrite(13, LOW); | |
} | |
#define SAMPLE 10 | |
unsigned long int poprzednio = millis() - SAMPLE; | |
byte stan = LOW; | |
void loop() { | |
unsigned long int teraz = millis(); | |
unsigned long int czas_zmiany = teraz - poprzednio; | |
if (czas_zmiany >= SAMPLE) { | |
if (stan == HIGH) { | |
stan = LOW; | |
} else { | |
stan = HIGH; | |
} | |
digitalWrite(13, stan); | |
poprzednio = teraz; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment