/////////////
// 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
void lightLedA () ;
//////////////
-// Second LED
-int ledB = 12; //Secondo 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
// interval at which to blink (milliseconds)
// Funzioni:
void lightLedA () {
- if(millis() - previousMillisA > intervalA) {
+ if (millis() > previousMillisA + intervalA) {
// save the last time you blinked the LED
previousMillisA = millis();
void lightLedB () {
long intervalB = 500;
static int ledStateB ; // https://www.arduino.cc/en/Reference/Static
- if(millis() - previousMillisB > intervalB) {
+ if (millis() > previousMillisB + intervalB) {
// save the last time you blinked the LED
previousMillisB = millis();