int main(){
sei(); //// Global interrupt enable
WDT_Init(); // Initialize Watchdog Timer in interrupt mode
DDRB |= (1 << PORTB0);
PORTB &= ~(1 << PORTB0); // Initialize LED to OFF
while(1){
}
}
void WDT_Init() {
WDTCSR = 0x00; // // Step 1: Disable WDT initially
WDTCSR |= (1 << WDCE) | (1 << WDE); // Step 2: Enable WDT configuration mode
WDTCSR = (1 << WDIE) | (1 << WDE) | (1 << WDP2) | (1 << WDP1) | (1 << WDP0);
//WDTCSR |= (1 << WDIE); // Enable WDT Interrupt Mode and disable reset
}
ISR(WDT_vect){
// Turn on the LED when WDT times out
PORTB |= (1 << PORTB0); // Set PB0 to HIGH (LED ON)
}