Konsep rambu lalu lintas pada percobaan ini : Rambu berlawanan
arah jarum jam, yang di mulai dari arah timur. Penjelasan : lampu menyala di mulai dari lampu
hijau timur, lalu di lanjutkan lampu kuning selatan di ikuti lampu hijau
selatan dan seterusnya. Dan selain titik yang hijau lampu nya merah.
Source Code
int mt=2; //merah
timur
int kt=3; //kuning
timur
int ht=4; //hijau
timur
int ms=5; //merah
selatan
int ks=6; //kuning
selatan
int hs=7; //hijau
selatan
int mb=8; //merah
barat
int kb=9; //kuning
barat
int hb=10; //hijau
barat
int mu=11; //merah
utara
int ku=12; //kuning
utara
int hu=13; //hijau
utara
void setup() {
pinMode (mt,OUTPUT);
pinMode (kt,OUTPUT);
pinMode (ht,OUTPUT);
pinMode (ms,OUTPUT);
pinMode (ks,OUTPUT);
pinMode (hs,OUTPUT);
pinMode (mb,OUTPUT);
pinMode (kb,OUTPUT);
pinMode (hb,OUTPUT);
pinMode (mu,OUTPUT);
pinMode (ku,OUTPUT);
pinMode (hu,OUTPUT);
}
void loop() {
//timur hijau
digitalWrite (ht,HIGH);
digitalWrite (mu,HIGH);
digitalWrite (mb,HIGH);
digitalWrite (ms,HIGH);
digitalWrite (ks,LOW);
digitalWrite (kb,LOW);
digitalWrite (ku,LOW);
digitalWrite (hs,LOW);
digitalWrite (hb,LOW);
digitalWrite (hu,LOW);
digitalWrite (mt,LOW);
digitalWrite (kt,LOW);
delay(10000);
//selatan kuning
digitalWrite (ks,HIGH);
digitalWrite (mt,HIGH);
digitalWrite (ms,LOW);
digitalWrite (ht,LOW);
delay (1000);
//selatan hijau
digitalWrite (hs,HIGH);
digitalWrite (mu,HIGH);
digitalWrite (mb,HIGH);
digitalWrite (mt,HIGH);
digitalWrite (ks,LOW);
digitalWrite (kb,LOW);
digitalWrite (ku,LOW);
digitalWrite (ht,LOW);
digitalWrite (hb,LOW);
digitalWrite (hu,LOW);
digitalWrite (kt,LOW);
delay (10000);
//barat kuning
digitalWrite (kb,HIGH);
digitalWrite (ms,HIGH);
digitalWrite (hs,LOW);
digitalWrite (mb,LOW);
delay (1000);
//barat hijau
digitalWrite (hb,HIGH);
digitalWrite (mu,HIGH);
digitalWrite (ms,HIGH);
digitalWrite (mt,HIGH);
digitalWrite (kb,LOW);
digitalWrite (ks,LOW);
digitalWrite (kt,LOW);
digitalWrite (ku,LOW);
digitalWrite (ht,LOW);
digitalWrite (hs,LOW);
digitalWrite (hu,LOW);
delay (10000);
//utara kuning
digitalWrite (ku,HIGH);
digitalWrite (mb,HIGH);
digitalWrite (hb,LOW);
digitalWrite (mu,LOW);
delay (1000);
//utara hijau
digitalWrite (hu,HIGH);
digitalWrite (mb,HIGH);
digitalWrite (ms,HIGH);
digitalWrite (mt,HIGH);
digitalWrite (ku,LOW);
digitalWrite (ks,LOW);
digitalWrite (kt,LOW);
digitalWrite (kb,LOW);
digitalWrite (ht,LOW);
digitalWrite (hs,LOW);
digitalWrite (hb,LOW);
delay (10000);
//kuning timur
digitalWrite (kt,HIGH);
digitalWrite (mu,HIGH);
digitalWrite (hu,LOW);
delay (1000);
}
No comments:
Post a Comment