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

Schematics

Skema Simulasi Lampu Lalu Lintas
Capture ijuseftune

Code

Coding simulasi lampu lalulintasArduino
// 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

4e805b489e201a39826e2e30ba91d9b2
Encik Nurul Hafidah
1 project • 2 followers
Contact

Comments

Add projectSign up / Login