Labels

Script Arduino simulasi Lampu lalu lintas 9 LED

pada udh taukan apa itu lampu lalu lintas :v
okeh... kali ini saya akan share script arduino untuk simulasi lampu merah
3 lampu merah artinya 9 led :3
saya mengambil latar simulasi di dunia asli... iya di bumi ini
tepatnya di pertigaan lampu merah purwosari... taukan.. harus tau :v
berikut gambar pertigaannya yg saya abadikan dalam bentuk epic paint :3
sorry kalo mirip banget :v

berikut merupakan script lampu merah untuk pertigaan Purwosari
ini script untuk arduino dengan 9 led



//program lampu_merah-pertigaanpurwosari
int m_mlg = 13;
int k_mlg = 12;
int h_mlg = 11;
int m_sby = 10;
int k_sby = 9;
int h_sby = 8;
int m_pas = 7;
int k_pas = 6;
int h_pas = 5;

void setup() {            
pinMode(m_mlg, OUTPUT);
pinMode(k_mlg, OUTPUT);
pinMode(h_mlg, OUTPUT);
pinMode(m_sby, OUTPUT);
pinMode(k_sby, OUTPUT);
pinMode(h_sby, OUTPUT);
pinMode(m_pas, OUTPUT);
pinMode(k_pas, OUTPUT);
pinMode(h_pas, OUTPUT);
}

void loop() {
digitalWrite(m_pas, HIGH);
digitalWrite(k_pas, LOW);
digitalWrite(h_pas, LOW);
digitalWrite(m_mlg, HIGH);

digitalWrite(k_mlg, LOW);
digitalWrite(h_mlg, LOW);
digitalWrite(m_sby, LOW);
digitalWrite(k_sby, LOW);
digitalWrite(h_sby, HIGH);
delay(5000);
digitalWrite(m_pas, HIGH);
digitalWrite(k_pas, LOW);
digitalWrite(h_pas, LOW);
digitalWrite(m_mlg, HIGH);
digitalWrite(k_mlg, LOW);
digitalWrite(h_mlg, LOW);
digitalWrite(k_sby, HIGH);
digitalWrite(h_sby, LOW);
delay(5000);
digitalWrite(m_pas, HIGH);
digitalWrite(k_pas, LOW);
digitalWrite(h_pas, LOW);
digitalWrite(m_mlg, LOW);
digitalWrite(k_mlg, HIGH);
digitalWrite(h_mlg, LOW);
digitalWrite(m_sby, HIGH);
digitalWrite(k_sby, LOW);
digitalWrite(h_mlg, LOW);
delay(5000);
digitalWrite(k_mlg, LOW);
digitalWrite(m_pas, HIGH);
digitalWrite(h_mlg, HIGH);
ZdigitalWrite(m_sby, HIGH);
delay(5000);
digitalWrite(h_mlg, LOW);
digitalWrite(k_sby, LOW);
digitalWrite(m_pas, HIGH);
digitalWrite(k_mlg, HIGH);
digitalWrite(m_sby, HIGH);
delay(5000);
digitalWrite(m_pas, LOW);
digitalWrite(k_pas, HIGH);
digitalWrite(h_pas, LOW);
digitalWrite(m_mlg, HIGH);
digitalWrite(k_mlg, LOW);
digitalWrite(h_mlg, LOW);
digitalWrite(m_sby, HIGH);
digitalWrite(k_sby, LOW);
digitalWrite(h_sby, LOW);
delay(5000);
digitalWrite(m_pas, LOW);
digitalWrite(k_pas, LOW);
digitalWrite(h_pas, HIGH);
digitalWrite(m_mlg, HIGH);
digitalWrite(k_mlg, LOW);
digitalWrite(h_mlg, LOW);
digitalWrite(m_sby, HIGH);
digitalWrite(k_sby, LOW);
digitalWrite(h_sby, LOW);
delay(5000);
ZZdigitalWrite(m_pas, LOW);
digitalWrite(k_pas, HIGH);
digitalWrite(h_pas, LOW);
digitalWrite(m_mlg, HIGH);
digitalWrite(k_mlg, LOW);
digitalWrite(h_mlg, LOW);
digitalWrite(m_sby, HIGH);
digitalWrite(k_sby, LOW);
digitalWrite(h_sby, LOW);
delay(5000);
digitalWrite(m_pas, HIGH);
digitalWrite(k_pas, LOW);
digitalWrite(h_pas, LOW);
digitalWrite(m_mlg, HIGH);
digitalWrite(k_mlg, LOW);
digitalWrite(h_mlg, LOW);
digitalWrite(m_sby, LOW);
digitalWrite(k_sby, HIGH);
digitalWrite(h_sby, LOW);
delay(5000);
}

No comments:

Post a Comment