Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsigned long previousMillis1 = 0;
- unsigned long previousMillis2 = 0;
- const long interval1 = 1000;
- const long interval2 = 500;
- void loop() {
- unsigned long currentMillis = millis();
- if (currentMillis - previousMillis1 >= interval1) {
- previousMillis1 = currentMillis;
- // Task 1 code
- }
- if (currentMillis - previousMillis2 >= interval2) {
- previousMillis2 = currentMillis;
- // Task 2 code
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement