#define RED 7
#define YELLOW 6
#define GREEN 5
void setup() {
Serial.begin(9600);
pinMode(RED, OUTPUT);
pinMode(YELLOW, OUTPUT);
pinMode(GREEN, OUTPUT);
digitalWrite(RED, LOW);
digitalWrite(YELLOW, LOW);
digitalWrite(GREEN, LOW);
}
void loop() {
Serial.println("Berhenti!!!");
digitalWrite(RED, HIGH);
digitalWrite(YELLOW, LOW);
digitalWrite(GREEN, LOW);
delay(5000);
digitalWrite(RED, LOW);
digitalWrite(YELLOW, HIGH);
digitalWrite(GREEN, LOW);
delay(500);
Serial.println("Gas");
digitalWrite(RED, LOW);
digitalWrite(YELLOW, LOW);
digitalWrite(GREEN, HIGH);
delay(2000);
}
/*
Pelatihan Arduino Week 2 (23/09/2022)
TX = Transiver
RX = Resiver
dipakai untuk berkomunikasi dengan laptop
Pin (+) --> LED --> Resistor --> Ground (-)
Anode +
Cathode -
PUSH BUTTON
Pull Down
Push button, dipush keluaran 1 ke MCU, dilepas 0
5v-button-pin-gnd
Pull Up
dipush keluaran 0, dilepas 1
5v-pin-button-gnd
POTENTIOMETER
resistor yang berubah ubah
*/