Power Saving Idea

I am considering using a digital out pin to send power to some switches I am monitoring the state of.

Instead of having 5 volts connected to input pins (and in turn the pull-down or pull-up resistors) whenever a switch remains in the closed position, I was planning on sending 5 volts to it with the digital out and only when the program actually needs to know the state of the switches.

Does anyone see any problems with this? (Over current is not a problem)

I realize this might not seem like a 'necessary' thing to do. Please do not respond with things like "why would you even need to do that?"

My reasons;
(1) if the chip is put to sleep for a month or more I want there to be as close to 0 power consumption as possible. Switches left close would be consuming small amounts of power because of the pull-down resistors.
(2) curiosity

Spark

The input pins would still require pull-down resistors, because if the switch(s) you are testing is not being pressed the input pin it is wired to will see a 'floating' input condition, no matter what the source of voltage is for the other side of the switches.

Lefty

Lefty is correct, you still need to pull-up / pull-down.

I'm guessing a bit, but...

Assuming that you are using push-to-make switches, I would not be surprised if having a pull-up / down resistor will actually reduce the current consumption, because CMOS uses current when changing from a 1 to a 0, so a floating input may flip the state. The resistor only draws any significant current when you press the button. Otherwise the only current is through it and into the very high impedance digital input. That current is probably unmeasurable compared to the current draw of the microcontroller.

You can reverse the circuit and use the internal pull up resistors, then you can disable them when not actually reading the switch.


Rob

Now see what you just did? You haven't really answered my question. So to clarify;

  • of course i will still need pull-down resistors. Without them I would constantly be getting false triggering.
  • the current I am trying to save would be between the [constant 5v] to [closed switch] to [pull-down resistor] to [ground].
    The new set up would be [digital out pin 5v] to [closed switch] to [pull-down resistor] to [ground].

The only difference between my current set up and the one I am suggesting would be that the 5v would not be constant.

So back to my original question...Does anyone see any problems with this?

Rob - I've thought about that but i'm worried that it might make things a bit "messy".

The only difference between my current set up and the one I am suggesting would be that the 5v would not be constant.

That's correct.

So back to my original question...Does anyone see any problems with this?

No, if have an extra output pin available, it will work as you wish.

Rob - I've thought about that but i'm worried that it might make things a bit "messy".

Thanks again Lefty. I suspect I'll be posting again soon once I start trying to underclock (no doubt I'll mess that up). Keep an eye out for it.

So: powerPin->pullUp/Down->switch-to-ground->sensePin

With 'powerPin' set LOW it acts as a pull-down on the sensePin to keep it from floating.

With 'powerPin set HIGH it acts as a pull-up on the sensePin and allows the switch to pull the line LOW when pressed.

Seems like it should work.

Perhaps another way would be to set the sensePin pinmode() to OUTPUT and set it LOW when not in use. This should have the same effect without using another pin and external resistor (the internal pull-up can be enabled when needed).

boolean buttonIsPressed(int sensePin)
    {
    boolean pinState;

    pinmode(sensePin, INPUT);
    digitalWrite(sensePin, HIGH);   // Enable the internal pull-up
    pinState = digitalRead(sensePin);
    digitalWrite(sensePin, LOW);   // Disable the internal pull-up
    pinmode(sensePin, OUTPUT);

    return !pinState;  // Button is active low.
    }