Hello,
I'm just getting back into creating Arduino sketches today after a couple years of not touching it (look what I've been missing!!!). Please pardon my newbish renewbness.
Is it possible to shut off a pin and reset pinMode in the loop? If anything, it would be great to turn off a pin, then just tell the Arduino to reset in the loop if needed.
I'm curious for power conservation reasons. Gathering supplies for a servo that points to the current status of things, it doesn't take much to get a servo to point to something (think Twister spinner, only powered by a servo and showing temperature instead of spots)... but then the servo will continue to draw power and I really don't need the power to hold the position of my nearly weightless pointer. Then if I decide to make this pointer thing battery powered, the battery will be quickly sucked dry just for the sake of pointing. :~
Any thoughts on specific methods I should look into? I can provide exact code later, possibly ten hours from now if that would help. I generally just need a nudge in the right direction though with no specific examples.
Thanks for any tips in advance. I truly appreciate it.
Is it possible to shut off a pin and reset pinMode in the loop?
Both are possible. Though changing the mode of a pin while the Arduino is running is not a usual thing to do, unless using a ping sensor.
If anything, it would be great to turn off a pin, then just tell the Arduino to reset in the loop if needed.
Reset what? Or, do you mean restart?
but then the servo will continue to draw power and I really don't need the power to hold the position
Not if you detach it. If you do, though, you need another way to unpower the servo, since the Arduino is not supposed to power servos. A transistor switched by another pin comes to mind.
Is it possible to shut off a pin and reset pinMode in the loop?
Both are possible. Though changing the mode of a pin while the Arduino is running is not a usual thing to do, unless using a ping sensor.
Depends on the type of device connected to the pin.
In some cases not only is it "normal" but it is required.
It is done whenever interfacing to a bi directional port since
you have to flip the pin between input mode to output mode.
It is done in a library like GLCDv3 on all the 8 data lines to read/write to the display memory.
It is also done for things like reading a keypad.
You scan across the columns/rows and flip the pins from inputs to output as you
do the scan to determine which key is being pressed.
It is also done in less obvious cases like 1 wire library to switch from output to "open collector" by switching
the pin from output to input with pullup on.