// Defines
#define PIN_RED_LED 7
#define PIN_YELLOW_LED 6
#define PIN_GREEN_LED 5

// Variablen
unsigned long redStart = 0;         // Startzeitpunkt Rot (Millisekunden)
unsigned long yellowStart = 5000;   // Startzeitpunkt Gelb (Millisekunden)
unsigned long greenStart = 7000;    // Startzeitpunkt Grün (Millisekunden)

unsigned long redDuration = 5000;     // Brenndauer Rot (Millisekunden)
unsigned long yellowDuration = 2000; // Brenndauer Gelb (Millisekunden)
unsigned long greenDuration = 5000;  // Brenndauer Grün (Millisekunden)

// Gesamtzykluszeit
unsigned long cycleDuration = redDuration + yellowDuration + greenDuration;

typedef unsigned long time_t;


void setup() {
  pinMode(PIN_RED_LED, OUTPUT);
  pinMode(PIN_YELLOW_LED, OUTPUT);
  pinMode(PIN_GREEN_LED, OUTPUT);
}

void loop() {
  // Aktuelle Zeit innerhalb des Zyklus berechnen
  time_t systemTime = millis();
  time_t cycleTime = systemTime % cycleDuration;

  // Rote-LED
  if (cycleTime >= redStart && cycleTime < redStart + redDuration) {
    digitalWrite(PIN_RED_LED, HIGH);
  } else {
    digitalWrite(PIN_RED_LED, LOW);
  }

  // Gelbe-LED
  if (cycleTime >= yellowStart && cycleTime < yellowStart + yellowDuration) {
    digitalWrite(PIN_YELLOW_LED, HIGH);
  } else {
    digitalWrite(PIN_YELLOW_LED, LOW);
  }

  // Grüne-LED
  if (cycleTime >= greenStart && cycleTime < greenStart + greenDuration) {
    digitalWrite(PIN_GREEN_LED, HIGH);
  } else {
    digitalWrite(PIN_GREEN_LED, LOW);
  }
}