const int lampu1 = 2;
const int lampu2 = 4;
const int saklar1 = 13;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(lampu1, OUTPUT);
pinMode(lampu2, OUTPUT);
pinMode(saklar1, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
if (digitalRead(saklar1) == LOW) {
digitalWrite(lampu1, LOW);
digitalWrite(lampu2, HIGH);
delay(1000);
digitalWrite(lampu2, LOW);
delay(1000);
} else {
digitalWrite(lampu1, HIGH);
digitalWrite(lampu2, LOW);
delay(1000);
digitalWrite(lampu1, LOW);
delay(1000);
}
}