// Test Arduino (328p) power reduction for power consumption // mode 0 - Do nothing - leave everything on (although uninitialised) // mode 1 - switch off the Analogue to Digital Converter (ADC) // Mode 2 - Switch off the serial UART // Mode 3 - Switch off Serial Peripheral Interface (SPI) // Mode 4 - Switch off Timer/counter 1 // Mode 5 - Switch off Timer/counter 0 (which affects delay(), millis() etc) // Mode 6 - Switch off Timer/counter 2 // Mode 7 - Switch off Two Wire Interface (TWI) // Mode 8 - Switch off ADC, SPI, TC1, TC2, TWI // Mode 9 - Switch everything off! // Results: // 0 = 39.5 41.0 // 1 = 39.4 40.0 // 2 = 40.1 40.0 // 3 = 39.1 39.9 // 4 = 40.3 40.8 // 5 = 38.3 38.5 // 6 = 39.1 39.4 // 7 = 38.9 39.1 // 8 = 35.9 36.0 // 9 = 33.7 33.6 int test_mode = 8; // Using this variable works around a bug in some systems // See: http://arduino.cc/forum/index.php/topic,59965.msg432768.html int delay_time = 10000; void setup() { // Power reduction register // Bit 7 = Two Wire Interface (TWI) // Bit 6 = Timer/counter 2 // Bit 5 = Timer/counter 0 // Bit 4 = reserved // Bit 3 = Timer/counter 1 // Bit 2 = Serial peripheral interface (SPI) // Bit 1 = USART0 // Bit 0 = ADC switch(test_mode) { case 0: PRR = 0x00; break; case 1: PRR = 0x01; break; case 2: PRR = 0x02; break; case 3: PRR = 0x04; break; case 4: PRR = 0x10; break; case 5: PRR = 0x20; break; case 6: PRR = 0x40; break; case 7: PRR = 0x80; break; case 8: PRR = 0xCD; break; case 9: PRR = 0xEF; break; } } // This is supposed to be a constant 'load'. Looping continuously may // cause variable current consumption, so I'm hoping a long delay will // mean the chip is in a 'constant' state. void loop() { delay(delay_time); }