#include "Led.h"
const int LED_ON = 500;
const int LED_OFF = 500;
const int n = 6; // numero de leds
unsigned long currentMillis, previousMillis;
const int pin[n] = {13, 12, 11, 10, 9, 8}; //array with the pins where leds are connected
Led myLed[n];
void setup() {
for (int i = 0; i < n; i++){
myLed[i].pin = pin[i]; // assign each led its corresponding pin
myLed[i].PinAsOutput(); // the pin of each led as output
myLed[i].state = false;
}
}
void loop() {
currentMillis = millis();
ledOnHandle();
ledOffHandle();
}
void ledOnHandle() {
if(myLed[0].state == false){
if( (currentMillis - previousMillis) >= LED_ON ){
previousMillis = currentMillis;
for (int i = 0; i < 6; i++){
myLed[i].LedOn(myLed[i]); //each led lights up
}
}
}
}
void ledOffHandle() {
if(myLed[0].state == true){
if( (currentMillis - previousMillis) >= LED_OFF ){
previousMillis = currentMillis;
for (int i = 0; i < 6; i++){
myLed[i].LedOff(myLed[i]); //each led lights off
}
}
}
}