// Test Arduino pin modes for power consumption // mode 0 // Make all pins into inputs (which is pretty much default arduino behaviour) // Mode 1 // Make all pins inputs, and enable the internal pull-up resistor // Mode 2 // Make all pins outputs, and set them all low // Mode 3 // Make all pins outputs and set them all high // Results // 0 = 41.1 41.1 // 1 = 31.2 31.1 // 2 = 30.1 30.0 // 3 = 34.9 34.9 int test_mode = 3; // 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() { int i; for(i = 0; i <= 19; i++) { switch(test_mode) { case 0: pinMode(i, INPUT); break; case 1: pinMode(i, INPUT); digitalWrite(i, HIGH); break; case 2: pinMode(i, OUTPUT); digitalWrite(i, LOW); break; case 3: pinMode(i, OUTPUT); digitalWrite(i, HIGH); 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); }