Encik Nurul Hafidah
Published © CC BY

Simulasi Lampu Lalu Lintas

pada project ini saya membuat lampu lalu lintas

EasyProtip1 hour149
Simulasi Lampu Lalu Lintas

Things used in this project

Hardware components

Arduino UNO R3
×1
Breadboard
×1
Resistor 220 ohm
×1
kabel Jumper
×1
LED (merah,kuning,hijau)
×1

Story

Read more

Schematics

Skema Simulasi Lampu Lalu Lintas

Capture ijuseftune

Code

Coding simulasi lampu lalulintas

Arduino
// inisialisasi PIN
int LedMerah = 13;
int LedKuning = 12;
int LedHijau = 11;

void setup() {
  // inisialisasi PIN Digital 13(LedMerah), 12(LedKuning), 11(LedHijau) sebagai output
  pinMode (LedMerah, OUTPUT);
  pinMode (LedKuning, OUTPUT);
  pinMode (LedHijau, OUTPUT);
  
}

void loop() {
  // LedHijau akan menyala 9 detik
  digitalWrite (LedMerah, LOW); 
  digitalWrite (LedKuning, LOW);
  digitalWrite (LedHijau, HIGH);
  delay (9000);
  
  // LedKuning mulai nyala sebelum 1 detik LedHijau mati
  digitalWrite (LedKuning, HIGH); //
  delay (1000);
  digitalWrite (LedKuning, HIGH);
  digitalWrite (LedHijau, LOW);
  delay (1000);
  
  // LedMerah nyala 7 detik  
  digitalWrite (LedKuning, LOW);
  digitalWrite (LedMerah, HIGH);
  delay (7000);
  
}

Credits

Encik Nurul Hafidah

Encik Nurul Hafidah

1 project • 2 followers

Comments

Add projectSign up / Login