/*
*/
#define LED1 26
#define LED2 27
#define LED3 25
void setup(void) {
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
}
void loop(void) {
led1Task(LED1);
led2Task(LED2, 600);
led3Task(LED3, 200);
}
void led1Task(int ledPin) {
static unsigned long timerStart = millis();
unsigned long timerNow = millis();
if (timerNow - timerStart >= 1000) {
timerStart = timerNow;
digitalWrite(ledPin, !digitalRead(ledPin));
}
}
void led2Task(int ledPin, int durata) {
static unsigned long timerStart = millis();
unsigned long timerNow = millis();
int tempoTrascorso = timerNow - timerStart;
if (tempoTrascorso >= durata) {
timerStart = timerNow;
digitalWrite(ledPin, !digitalRead(ledPin));
}
}
void led3Task(int ledPin, int durata) {
static unsigned long timerStart = millis();
unsigned long timerNow = millis();
int tempoTrascorso = timerNow - timerStart;
if (tempoTrascorso >= durata) {
timerStart = timerNow;
digitalWrite(ledPin, !digitalRead(ledPin));
}
}