const int LED1_PIN = 2;
const int LED2_PIN = 3;
unsigned long previousMillis1 = 0;
unsigned long previousMillis2 = 0;
const long interval1_short = 100; // Blink duration for '1' (short blink) in milliseconds
const long interval1_long = 200; // Blink duration for '2' (longer blink) in milliseconds
int pattern[] = {1, 1, 2, 1, 1, 1, 2}; // Pattern sequence for LED1
int patternIndex = 0; // Index to track the current position in the pattern
void setup() {
pinMode(LED1_PIN, OUTPUT);
pinMode(LED2_PIN, OUTPUT);
}
void loop() {
unsigned long currentMillis = millis();
// Blink LED1 based on the pattern sequence
if (currentMillis - previousMillis1 >= (pattern[patternIndex] == 1 ? interval1_short : interval1_long)) {
previousMillis1 = currentMillis;
digitalWrite(LED1_PIN, HIGH); // Turn on LED1
// Set the duration for LED1 based on the pattern
long duration = (pattern[patternIndex] == 1 ? interval1_short : interval1_long);
// If it's a short blink, wait 50ms and then turn off
if (pattern[patternIndex] == 1) {
delay(50);
}
digitalWrite(LED1_PIN, LOW); // Turn off LED1
delay(duration - (pattern[patternIndex] == 1 ? 50 : 0)); // Wait for the remaining duration
// Move to the next position in the pattern
patternIndex = (patternIndex + 1) % (sizeof(pattern) / sizeof(pattern[0]));
}
// Blink LED2 (If needed) - You can keep this part or remove it if not required
if (currentMillis - previousMillis2 >= 1000) {
previousMillis2 = currentMillis;
digitalWrite(LED2_PIN, !digitalRead(LED2_PIN)); // Toggle LED2 state every 1 second
}
}