int pin[] = {15, 4, 5, 18};
int ledState = LOW;
unsigned long previousMillis = 0;
long interval = 1000;
int ledState1 = LOW;
unsigned long previousMillis1 = 0;
long interval1 = 1000;
int ledState2 = LOW;
unsigned long previousMillis2 = 0;
long interval2 = 1000;
int ledState3 = LOW;
unsigned long previousMillis3 = 0;
long interval3 = 1000;
void setup() {
for (int i = 0; i <= 3; i++) {
pinMode(pin[i], OUTPUT);
}
}
void loop() {
/*
for (int i = 0; i <= 3; i++) {
digitalWrite(pin[i], HIGH);
digitalWrite(pin[i], 0);
delay(1000);
}
*/
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW) {
ledState = HIGH;
interval = 300;
} else {
ledState = LOW;
interval = 1500;
}
// set the LED with the ledState of the variable:
digitalWrite(15, ledState);
}
unsigned long currentMillis1 = millis();
if (currentMillis1 - previousMillis1 >= interval1) {
// save the last time you blinked the LED
previousMillis1 = currentMillis1;
// if the LED is off turn it on and vice-versa:
if (ledState1 == LOW) {
ledState1 = HIGH;
interval1 = 1500;
} else {
ledState1 = LOW;
interval1 = 300;
}
// set the LED with the ledState of the variable:
digitalWrite(4, ledState1);
}
unsigned long currentMillis2 = millis();
if (currentMillis2 - previousMillis2 >= interval2) {
// save the last time you blinked the LED
previousMillis2 = currentMillis2;
// if the LED is off turn it on and vice-versa:
if (ledState2 == LOW) {
ledState2 = HIGH;
} else {
ledState2 = LOW;
}
// set the LED with the ledState of the variable:
digitalWrite(5, ledState2);
}
unsigned long currentMillis3 = millis();
if (currentMillis3 - previousMillis3 >= interval3) {
// save the last time you blinked the LED
previousMillis3 = currentMillis3;
// if the LED is off turn it on and vice-versa:
if (ledState3 == LOW) {
ledState3 = HIGH;
} else {
ledState3 = LOW;
}
// set the LED with the ledState of the variable:
digitalWrite(18, ledState3);
}
}