// //belajar menghidupkan lampu menggunakan pusbaten
// void setup() {
// // put your setup code here, to run once:
// pinMode(13, OUTPUT);
// pinMode(7, INPUT);
// }
// void loop() {
// if(digitalRead(7)== HIGH){
// digitalWrite(13, HIGH);
// //Serial.begin(9600);
// }
// else{
// digitalWrite(13, LOW);
// }
// }
#define LED_hijau 13
#define LED_biru 12
#define LED_merah 10
#define tombol 7
int status = 0;
void setup() {
pinMode(LED_hijau, OUTPUT);
pinMode(tombol, INPUT);
pinMode(LED_biru, OUTPUT);
pinMode(LED_merah, OUTPUT);
pinMode(LED_hijau, LOW);
pinMode(LED_biru, LOW);
pinMode(LED_merah, LOW);
}
void loop() {
if(digitalRead(tombol)== HIGH){
status++;
delay(100);
}
if(status == 1){
digitalWrite(LED_hijau, HIGH);
}
else if (status == 2){
digitalWrite(LED_biru, HIGH);
}
else if (status == 3){
digitalWrite(LED_merah, HIGH);
}
else if(status == 4){
status = 0;
}
else{
digitalWrite(LED_hijau, LOW);
digitalWrite(LED_biru, LOW);
digitalWrite(LED_merah, LOW);
}
}