void setup() {
// put your setup code here, to run once:
for (int x=2;x<14;x++) {
pinMode (x, OUTPUT); //Memfungsikan pin 2 hingga 13 sebagai OUTPUT
digitalWrite (x, LOW); //Mematikan semua lampu
}
//Menghidupkan lampu Merah jalan Utara, Barat, Selatan, Timur
digitalWrite (2, HIGH);
digitalWrite (5, HIGH);
digitalWrite (8, HIGH);
digitalWrite (11, HIGH);
delay (500);
}
void loop() {
// put your main code here, to run repeatedly:
Jalan_Utara ();
delay (500);
Jalan_Barat ();
delay (500);
Jalan_Selatan ();
delay (500);
Jalan_Timur ();
delay (500);
}
void Jalan_Utara(){
digitalWrite (2, LOW);
digitalWrite (4, HIGH);
delay (5000);
digitalWrite (4, LOW);
digitalWrite (3, HIGH);
delay (500);
digitalWrite (3, LOW);
digitalWrite (2, HIGH);
}
void Jalan_Barat(){
digitalWrite (5, LOW);
digitalWrite (7, HIGH);
delay (5000);
digitalWrite (7, LOW);
digitalWrite (6, HIGH);
delay (500);
digitalWrite (6, LOW);
digitalWrite (5, HIGH);
}
void Jalan_Selatan(){
digitalWrite (8, LOW);
digitalWrite (10, HIGH);
delay (5000);
digitalWrite (10, LOW);
digitalWrite (9, HIGH);
delay (500);
digitalWrite (9, LOW);
digitalWrite (8, HIGH);
}
void Jalan_Timur(){
digitalWrite (11, LOW);
digitalWrite (13, HIGH);
delay (5000);
digitalWrite (13, LOW);
digitalWrite (12, HIGH);
delay (500);
digitalWrite (12, LOW);
digitalWrite (11, HIGH);
}