Skip to content

Instantly share code, notes, and snippets.

@rafalw
Created April 5, 2016 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafalw/5927cf10d0d98d305af41b04aa580741 to your computer and use it in GitHub Desktop.
Save rafalw/5927cf10d0d98d305af41b04aa580741 to your computer and use it in GitHub Desktop.
Alternatywa dla delay() - bez użycia bibliotek typu Timer.h
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