Power management is crucial for battery-operated devices and energy-efficient applications. Understanding different power modes and techniques can significantly extend battery life.
// Enable sleep mode void enableSleep() { // Set sleep mode to power down SMCR |= (1 << SM1); // Enable sleep SMCR |= (1 << SE); // Enter sleep mode asm volatile("sleep"); } // Wake up on interrupt ISR(INT0_vect) { // Disable sleep SMCR &= ~(1 << SE); }