X-Git-Url: http://git.piffa.net/web?a=blobdiff_plain;f=multitasking%2FBlinkWithoutDelay_3_funzione%2FBlinkWithoutDelay_3_funzione.ino;h=93387bd7d4d174efdad86c442670b01dc1f028bd;hb=17b4fe57f20ce15396a69ef7fdc87a7342ba0cb7;hp=5f5f2aba16ffdc510edffb190419135ae3f2704e;hpb=f3ffb63f53d580f0853e6b32c8ec377a7eac67f7;p=sketchbook_andrea diff --git a/multitasking/BlinkWithoutDelay_3_funzione/BlinkWithoutDelay_3_funzione.ino b/multitasking/BlinkWithoutDelay_3_funzione/BlinkWithoutDelay_3_funzione.ino index 5f5f2ab..93387bd 100644 --- a/multitasking/BlinkWithoutDelay_3_funzione/BlinkWithoutDelay_3_funzione.ino +++ b/multitasking/BlinkWithoutDelay_3_funzione/BlinkWithoutDelay_3_funzione.ino @@ -12,20 +12,23 @@ ///////////// // First LED -int ledA = 13; // the number of the LED pin +const int ledA = 13; // the number of the LED pin // Variables will change: int ledStateA = LOW; // ledState used to set the LED long previousMillisA = 0; // will store last time LED was updated // the follow variables is a long because the time, measured in miliseconds, // will quickly become a bigger number than can be stored in an int. long intervalA = 1000; // interval at which to blink (milliseconds) +void lightLedA () ; ////////////// -// Second LED -int ledB = 12; //Secondo LED -int ledStateB = LOW; // ledState used to set the LED +// Second LED +// Now with less global variables thanks to static (see function body) +const int ledB = 12; //Secondo LED + // ledState used to set the LED long previousMillisB = 0; // will store last time LED was updated -long intervalB = 500; // interval at which to blink (milliseconds) + // interval at which to blink (milliseconds) +void lightLedB () ; void setup() { @@ -60,6 +63,8 @@ void lightLedA () { } void lightLedB () { + long intervalB = 500; + static int ledStateB ; // https://www.arduino.cc/en/Reference/Static if(millis() - previousMillisB > intervalB) { // save the last time you blinked the LED previousMillisB = millis();