On - Off Switch with a momentary Button

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!

Moderator: phalanx

Post Reply
tglaser92
Posts: 3
Joined: Tue Aug 07, 2018 1:53 pm

On - Off Switch with a momentary Button

Post by tglaser92 » Tue Aug 07, 2018 2:04 pm

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

lyndon
Support Volunteer
Posts: 1611
Joined: Thu Jul 17, 2008 6:37 pm
Location: Minnesota, USA

Re: On - Off Switch with a momentary Button

Post by lyndon » Tue Aug 07, 2018 7:08 pm

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?

tglaser92
Posts: 3
Joined: Tue Aug 07, 2018 1:53 pm

Re: On - Off Switch with a momentary Button

Post by tglaser92 » Wed Aug 08, 2018 10:28 am

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

lyndon
Support Volunteer
Posts: 1611
Joined: Thu Jul 17, 2008 6:37 pm
Location: Minnesota, USA

Re: On - Off Switch with a momentary Button

Post by lyndon » Wed Aug 08, 2018 11:17 am

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 :-)

Post Reply