const int merah1 = 2;
const int kuning1 = 3;
const int hijau1 = 4;
const int merah2 = 5;
const int kuning2 = 6;
const int hijau2 = 7;
const int merah3 = 8;
const int kuning3 = 9;
const int hijau3 = 10;
void setup() {
pinMode(merah1, OUTPUT);
pinMode(kuning1, OUTPUT);
pinMode(hijau1, OUTPUT);
pinMode(merah2, OUTPUT);
pinMode(kuning2, OUTPUT);
pinMode(hijau2, OUTPUT);
pinMode(merah3, OUTPUT);
pinMode(kuning3, OUTPUT);
pinMode(hijau3, OUTPUT);
}
void loop() {
// Cabang 1 hijau
digitalWrite(hijau1, HIGH);
digitalWrite(kuning1, LOW);
digitalWrite(merah1, LOW);
digitalWrite(hijau2, LOW);
digitalWrite(kuning2, LOW);
digitalWrite(merah2, HIGH);
digitalWrite(hijau3, LOW);
digitalWrite(kuning3, LOW);
digitalWrite(merah3, HIGH);
delay(5000); // Tunggu 5 detik
// Cabang 1 kuning
digitalWrite(hijau1, LOW);
digitalWrite(kuning1, HIGH);
digitalWrite(merah1, LOW);
digitalWrite(hijau2, LOW);
digitalWrite(kuning2, HIGH);
digitalWrite(merah2, LOW);
delay(2000); // Tunggu 2 detik
// Cabang 1 merah, cabang 2 hijau
digitalWrite(hijau1, LOW);
digitalWrite(kuning1, LOW);
digitalWrite(merah1, HIGH);
digitalWrite(hijau2, HIGH);
digitalWrite(kuning2, LOW);
digitalWrite(merah2, LOW);
digitalWrite(hijau3, LOW);
digitalWrite(kuning3, LOW);
digitalWrite(merah3, HIGH);
delay(5000);
// Cabang 1 hijau
digitalWrite(hijau1, LOW);
digitalWrite(kuning1, LOW);
digitalWrite(merah1, HIGH);
digitalWrite(hijau2, HIGH);
digitalWrite(kuning2, LOW);
digitalWrite(merah2, LOW);
digitalWrite(hijau3, LOW);
digitalWrite(kuning3, LOW);
digitalWrite(merah3, HIGH);
delay(5000); // Tunggu 5 detik
// Cabang 1 kuning
digitalWrite(hijau2, LOW);
digitalWrite(kuning2, HIGH);
digitalWrite(merah2, LOW);
digitalWrite(hijau3, LOW);
digitalWrite(kuning3, HIGH);
digitalWrite(merah3, LOW);
delay(2000); // Tunggu 2 detik
// Cabang 1 merah, cabang 2 hijau
digitalWrite(hijau1, LOW);
digitalWrite(kuning1, LOW);
digitalWrite(merah1, HIGH);
digitalWrite(hijau2, LOW);
digitalWrite(kuning2, LOW);
digitalWrite(merah2, HIGH);
digitalWrite(hijau3, HIGH);
digitalWrite(kuning3, LOW);
digitalWrite(merah3, LOW);
delay(5000);
// Cabang 1 merah, cabang 2 hijau
digitalWrite(hijau1, LOW);
digitalWrite(kuning1, LOW);
digitalWrite(merah1, HIGH);
digitalWrite(hijau2, LOW);
digitalWrite(kuning2, LOW);
digitalWrite(merah2, HIGH);
digitalWrite(hijau3, HIGH);
digitalWrite(kuning3, LOW);
digitalWrite(merah3, LOW);
delay(5000);
// Cabang 1 kuning
digitalWrite(hijau3, LOW);
digitalWrite(kuning3, HIGH);
digitalWrite(merah3, LOW);
digitalWrite(hijau1, LOW);
digitalWrite(kuning1, HIGH);
digitalWrite(merah1, LOW);
delay(2000); // Tunggu 2 detik
// Cabang 1 hijau
digitalWrite(hijau1, HIGH);
digitalWrite(kuning1, LOW);
digitalWrite(merah1, LOW);
digitalWrite(hijau2, LOW);
digitalWrite(kuning2, LOW);
digitalWrite(merah2, HIGH);
digitalWrite(hijau3, LOW);
digitalWrite(kuning3, LOW);
digitalWrite(merah3, HIGH);
delay(5000); // Tunggu 5 detik
// ... (ulangi untuk cabang 2 dan 3)
}