Multi-function Pushbutton

Hi there,

I'm looking for a circuit where I can press a single pushbutton that has several modes. For example, the first push would tell the Arduino to turn an LED on, the second push would tell the Arduino to do something else like change the LED brightness, etc. and then the last push would turn the LED off again.

  • I know how to do this if the Arduino never goes to sleep (since the Arduino can simply count the number of presses), but this is trickier because I want the Arduino to go to sleep after changing the LED state (on/off/brightness). For example, if the LED is off and the button is pushed, the Arduino should wake up via the pushbutton, turn the LED on to 100%, and go back to sleep. If the button is pushed again, the Arduino should wake up, turn the LED to 50%, and go to sleep. Etc. etc.

  • I'm thinking that to even keep the LED on after the Arduino goes to sleep would involve a soft latch like described here. Let me know if I'm wrong.

  • I want to avoid using EEPROM because of a limited number of write cycles. If I use EEPROM I can store the number of button presses and reset it after the last press, but this would eat up quite a few cycles and it's not the best idea.

Any ideas? Thanks!

androidfanboy:
For example, if the LED is off and the button is pushed, the Arduino should wake up via the pushbutton, turn the LED on to 100%, and go back to sleep.

All that on a single push of the button? So you have some kind of external circuit that takes care of the LED dimming while the Arduino is asleep? if so, maybe you can read back the LED brightness from that circuit.

Yea I would have a PWM dimmer of sorts, although that's not set in stone yet either. I'm thinking maybe I'll just be better off having the Arduino stay on during the process. Are there things that can be done to save power when the Arduino is on? For example, could I turn of the ADC and reduce clock rate? It would only need to set the brightness with analogWrite () and take note of other button presses.

Yes - that will save power - but the savings are nothing compared to the power wasted by the external components of the Arduino (such as the regulator, USB/TTL converter and power LED).

If you want to go low power, dump the Arduino and get a barebones ATmega (or ATtiny for even lower power consumption). That alone will drop you from 50-80 mA to about 5 mA. After that lowering clock speeds and so can shave off a few more mA. Sleep mode can get you to the uA range (while an Arduino board in sleep mode still uses some 50 mA).

Yea that's actually what I am going to use but I just said Arduino since it was easier to say :slight_smile:

I'll probably just do it that way and use an interrupt to set a logic flag so I can increment the counter each time the button is pressed.

Thanks!