Program Arduino, (Guru Pengampu : Dede Yusuf, S.
Pd), Produktif Elektronika Industri
Program Traffic Light pada Arduino
//SKETCH LAMPU TRAFFICT LIGHT PERTIGAAN JALAN
//DEFINISIKAN
int UM=1;//Utara Merah
int UK=2;//Utara Kuning
int UH=3;//Utara Hijau
int TM=4;//Timur Merah
int TK=5;//Timur Kuning
int TH=6;//Timur Hijau
int SM=7;//Selatan Merah
int SK=8;//Selatan Kuning
int SH=9;//Selatan Hijau
//PROGRAMMER NBS
void setup() {
pinMode(UM, OUTPUT);
pinMode(UK, OUTPUT);
pinMode(UH, OUTPUT);
pinMode(TM, OUTPUT);
pinMode(TK, OUTPUT);
pinMode(TH, OUTPUT);
pinMode(SM, OUTPUT);
pinMode(SK, OUTPUT);
pinMode(SH, OUTPUT);
//RANCANGAN NBS
void loop() {
//ARAH DARI UTARA JALAN
digitalWrite(UM,LOW);
digitalWrite(UK,LOW);
digitalWrite(UH,HIGH);
digitalWrite(TM,HIGH);
digitalWrite(TK,LOW);
digitalWrite(TH,LOW);
digitalWrite(SM,HIGH);
digitalWrite(SK,LOW);
digitalWrite(SH,LOW);
delay(6000);
digitalWrite(UM,LOW);
digitalWrite(UK,HIGH);
digitalWrite(UH,LOW);
digitalWrite(TM,HIGH);
digitalWrite(TK,LOW);
digitalWrite(TH,LOW);
digitalWrite(SM,HIGH);
digitalWrite(SK,LOW);
digitalWrite(SH,LOW);
delay(1000);
//ARAH DARI TIMUR JALAN
digitalWrite(UM,HIGH);
digitalWrite(UK,LOW);
digitalWrite(UH,LOW);
digitalWrite(TM,LOW);
digitalWrite(TK,LOW);
digitalWrite(TH,HIGH);
digitalWrite(SM,HIGH);
digitalWrite(SK,LOW);
digitalWrite(SH,LOW);
delay(6000);
digitalWrite(UM,HIGH);
digitalWrite(UK,LOW);
digitalWrite(UH,LOW);
digitalWrite(TM,LOW);
digitalWrite(TK,HIGH);
digitalWrite(TH,LOW);
digitalWrite(SM,HIGH);
digitalWrite(SK,LOW);
digitalWrite(SH,LOW);
delay(1000);
//ARAH DARI SELATAN JALAN
digitalWrite(UM,HIGH);
digitalWrite(UK,LOW);
digitalWrite(UH,LOW);
digitalWrite(TM,HIGH);
digitalWrite(TK,LOW);
digitalWrite(TH,LOW);
digitalWrite(SM,LOW);
digitalWrite(SK,LOW);
digitalWrite(SH,HIGH);
delay(6000);
digitalWrite(UM,HIGH);
digitalWrite(UK,LOW);
digitalWrite(UH,LOW);
digitalWrite(TM,HIGH);
digitalWrite(TK,LOW);
digitalWrite(TH,LOW);
digitalWrite(SM,LOW);
digitalWrite(SK,HIGH);
digitalWrite(SH,LOW);
delay(1000);
}
Gambar rangkaian skema rangkaian arduino Traffic Light :