/*
Pelatihan IoT3 - 14 Internet of Things (IoT) DTS PROA Batch 3
(Digitalent Scholarship Professional Academy)
created 6 Agustus 2022
by Muhammad Sudarsono
modified 6 Agustus 2022
Copyright © 2022 Indobot Academy
*/
#define LED_hijau 13. //PIN Led 13
#define LED_biru 12. //PIN Led 12
#define LED_Merah 11 //PIN Led 11
#define tombol 7 //PIN Baten 7
int status = 0; // Variabel yang menampung Nilai Pusbaten 0
void setup() {
// put your setup code here, to run once:
pinMode(LED_hijau, OUTPUT); //Inialisasi LED Hiaju
pinMode(LED_biru, OUTPUT); //Inialisasi LED Biru
pinMode(LED_Merah, OUTPUT); //Inialisasi LED Merah
pinMode(tombol, INPUT); //Inialisasi Pusbaten
digitalWrite(LED_hijau, LOW); //Defold led hijau = 0
digitalWrite(LED_biru, LOW); //Defold led Biru = 0
digitalWrite(LED_Merah, LOW); //Defold led Merah = 0
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(tombol) == HIGH){
status++;
delay(100);
}
if(status == 1){
digitalWrite(LED_hijau, HIGH);
Serial.println("LED_Hijau Menyala");
}
else if(status == 2){
digitalWrite(LED_biru, HIGH);
Serial.println("LED_Hijau dan LED_Biru Menyala");
}
else if(status == 3){
digitalWrite(LED_Merah, HIGH);
Serial.println("LED_Hijau, LED_Biru dan LED_Merah Menyala");
}
else if(status == 4){
status = 0;
}
else{
digitalWrite(LED_hijau, LOW);
digitalWrite(LED_biru, LOW);
digitalWrite(LED_Merah, LOW);
Serial.println("Semua Led Mati");
}
}