/*
PROGAM PEREMPATAN

Link: https://wokwi.com/projects/341373428311261779

Created by reazon / k17
*/

int red_lamp[] = {13, 10, 7},
    utara[] = {13, 12, 11}, 
    timur[] = {10, 9, 8},
    selatan[] = {7, 6, 5},
    delayIn300[] = {2, 8};

void setup() {
  for(int i = 5; i < 14; i++){
    pinMode(i, OUTPUT);
  }
}

void loop() {
  jalan(utara);
  jalan(timur);
  jalan(selatan);
}

void jalan(int direction_pins[]) {
  for(int i : red_lamp) {
    digitalWrite(i, i != direction_pins[0]);
  }
  digitalWrite(direction_pins[1], !0);
  delay(delayIn300[0] * 300);
  digitalWrite(direction_pins[1], !1);
  digitalWrite(direction_pins[2], !0);
  delay(delayIn300[1] * 300);
  digitalWrite(direction_pins[2], !1);
  digitalWrite(direction_pins[1], !0);
  delay(delayIn300[0] * 300) ;
  digitalWrite(direction_pins[1], !1);
}