#include <LiquidCrystal.h>
const int redPin = 3;
const int yellowPin = 5;
const int greenPin = 6;
const int rs = 7, en = 8, d4 = 9, d5 = 10, d6 = 11, d7 = 12;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
pinMode(redPin, OUTPUT);
pinMode(yellowPin, OUTPUT);
pinMode(greenPin, OUTPUT);
lcd.begin(16, 2);
}
void loop() {
digitalWrite(redPin, HIGH);
lcd.clear();
lcd.print("Lampu Merah!");
lcd.setCursor(0, 1);
lcd.print("Berhenti!");
delay(9000);
digitalWrite(redPin, LOW);
digitalWrite(yellowPin, HIGH);
lcd.clear();
lcd.print("Lampu Kuning!");
lcd.setCursor(0, 1);
lcd.print("Hati-hati!");
delay(3000);
digitalWrite(yellowPin, LOW);
digitalWrite(greenPin, HIGH);
lcd.clear();
lcd.print("Lampu Hijau!");
lcd.setCursor(0, 1);
lcd.print("Jalan!");
delay(8000);
lcd.clear();
lcd.print("Semoga Selamat!");
lcd.setCursor(0, 1);
lcd.print("Sampai Tujuan!");
delay(2000);
digitalWrite(greenPin, LOW);
digitalWrite(yellowPin, HIGH);
lcd.clear();
lcd.print("Lampu Kuning!");
lcd.setCursor(0, 1);
lcd.print("Hati-hati!");
delay(1500);
digitalWrite(yellowPin, LOW);
digitalWrite(redPin, HIGH);
lcd.clear();
lcd.print("Lampu Merah!");
lcd.setCursor(0, 1);
lcd.print("Berhenti!");
delay(9000);
digitalWrite(redPin, LOW);
}