SparkFun Forums 

Where electronics enthusiasts find answers.

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!
By tglaser92
#199967
Hello all,

I'm looking for a clever way to turn a momentary button into a 2-state toggle switch using a bit of hardware (and software if necessary). The SPST switch I'm currently using is far too small and makes it difficult to control when in the field, so I'd like to move over to a push button. The module I've made runs off of a 1S lipo battery (<4v) and draws a small amount of amperage (<<200mA).

I've seen a few mock ups using a secondary microchip like the ATtiny4 to act as a kind of a relay as well as some bulkier hardware schematics, but before testing this all myself I'm hoping someone here can lend a bit of experience.

There's not a ton of extra space on the board, so bonus points for a compact design.

Thanks,
Twain
By lyndon
#199971
I would go the ATTiny route or even the Arduino route. By the time you have all the bits for a DIY AT Tiny board, you're past the price of a cheap Arduino. Alternately, you could use a binary counter and every time you close the switch, you get a toggle on D0. But here, you'll need some kind of debounce, and by this point, we're right back at the Arduino :-)

And just noticed the bit about the lack of space: how much space are we talking about, exactly?
By tglaser92
#199986
I could make room for a Teensy I suppose...I was concerned about the power that it'll consume while waiting to be turned on, but it's so little that it really wont matter.

While not the most elegant design, that will certainly do the trick.

Thanks Lyndon
By lyndon
#199987
A Teensy is awfully big. An Adafruit Trinket is smaller. I was a bit harsh on the pricing statement: you can pick up an easy-to-program AVR like a Tiny13 and program it with a SOIC clip if you don't want to take up the space for a programming header and the cost in single units is only about $0.99 (I can buy Arduinos for $2.50). If this is on a PC board you're laying out yourself and you're building multiple units, I'd suggest a TagConnect header if you are space constrained.

PM me if this is the way you want to go and need some code: it's pretty simple to setup and it'll give me an excuse for a blog post :-)