const byte buttonPin = 2;
const byte ledPin = 8;
volatile bool ledState = LOW;
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
attachInterrupt(digitalPinToInterrupt(buttonPin), handleInterrupt, FALLING);
}
void loop() {
Serial.println("Program sibuk, tunggu 1 detik...");
delay(1000);
}
void handleInterrupt() {
ledState = !ledState;
digitalWrite(ledPin, ledState);
}