Toggling Lights with a push button

crutschow

Joined Mar 14, 2008
38,525
Below is the LTspice simulation of sghioto's 555 circuit in post #19 using a single push-button.
Its advantage is that the 555 output can directly drive most small 12V relays.
The protection diode for the relay coil load is not needed, since the 555 has a totem-pole output with an emitter-follower as the high-side driver, so when the output goes low, it will continue to conduct the inductive coil current and prevent any significant reverse spikes.
The circuit also inherently ignores any switch contact bounce.

The simulation shows the output (yellow trace) toggling for each PB press (green trace).
The red trace shows the capacitor voltage for the various circuit states.

1641530791065.png
 
Last edited:

Sensacell

Joined Jun 19, 2012
3,785
Dave Jones did a nice video on a discrete transistor version which is rather clever.
It incorporates the power switch, no relay or other stuff needed to switch the load.

 

MisterBill2

Joined Jan 23, 2018
27,557
The TS was rather specific in wanting to use the single button on the light. So either an alternate action relay or a "T" flipflop, such as a CD4013. For the simple debounce circuit, use a capacitor beteen the CLK input and the common negative, and about a 1000 ohm resistor between the positive source and the N.O. button, for current limiting when charging the cap. The time constant will be longer than the bounce on "make" and it will also take care of any bounce on break. And you can power the 4013 on up to 15 volts, which will allow it to provide plenty of base drive current for the pass transistor. It may not provide a high enough gate voltage to turn a mosfet on completely, which is why I suggest using an NPN bipolar device.
The 555 circuit is interesting, not sure how critical the values are.
 
Last edited:

crutschow

Joined Mar 14, 2008
38,525
such as a CD4013. For the simple debounce circuit, use a capacitor beteen the CLK input and the common negative, and about a 1000 ohm resistor between the positive source and the N.O. button,
That's not the best solution for debounce, since that gives a slow clock rise-time and the CD4013 has a minimum clock rise-tie spec for proper operation.
Better to use a delay between the /Q output and the D input as shown in post #5.
 

crutschow

Joined Mar 14, 2008
38,525
The 555 circuit is interesting, not sure how critical the values are.
Not particularly critical.

The the equivalent parallel resistance of R1-R3 should be no higher than about 1/10th the value of R2.
And the R1||R3 C1 time-constant just has to be long enough to trigger the 555 THRES and TRIG inputs.

The circuit is insensitive to contact-bounce or how long the button is pushed.
 

MisterBill2

Joined Jan 23, 2018
27,557
That's not the best solution for debounce, since that gives a slow clock rise-time and the CD4013 has a minimum clock rise-tie spec for proper operation.
Better to use a delay between the /Q output and the D input as shown in post #5.
It seems to have worked for me, and I am not sure about how the other method works with button release bounce.
 

crutschow

Joined Mar 14, 2008
38,525
t seems to have worked for me,
It may work for some but not all ICs
It's not good design practice to use a circuit outside its design limits.
I am not sure about how the other method works with button release bounce.
That's a good point.
Switch bounce on release can be a problem also and the delayed D input approach won't work for that.

The circuit in post #8 using inverters, and the 555 circuit, which both operate on a similar principle, ignore both close and release switch bounce.
 
Last edited:

djsfantasi

Joined Apr 11, 2010
9,237
And finally, someone (me) is going to suggest a μprocessor.

An ATTiny can be programmed via the Arduino IDE and a Sparkfun programmer. Debouncing can be handled in software. And toggling is simple in software and can be done with one line of code.

Plus, you have the added benefit of using multiple button presses to activate different options. If the additional lights are RGB, multiple presses can activate different colors.
 

MrSalts

Joined Apr 2, 2020
2,767
Seriously? Nobody has recommended a PIC, Arduino or RPi yet?
And finally, someone (me) is going to suggest a μprocessor.

An ATTiny can be programmed via the Arduino IDE and a Sparkfun programmer. Debouncing can be handled in software. And toggling is simple in software and can be done with one line of code.

Plus, you have the added benefit of using multiple button presses to activate different options. If the additional lights are RGB, multiple presses can activate different colors.
Or a simple 8 pin Picmicro.
And we have a winner (and a close second).
 

MisterBill2

Joined Jan 23, 2018
27,557
Of course, the single thing being controlled is an individual light source, probably with limited real estate for controls, and no desire for a constantly powered processor that must be programmed, and which certainly has a limited production life. And now another question: Is there any chance that the push switch is really an alternate action device? Certainly that possibility merits investigation.
 

Thread Starter

teenflon5

Joined Apr 19, 2021
27
Thanks all, My first thought was using an arduino nano as I'm very familiar with them but wanted to explore electronics solutions to see if there was an easier option. I like the diagrams for doing this with a latching relay with resistors and capacitors to remove the noise, but as I already have an arduino nano spare I think I will just use that this time.

My plan is to power the device from a USB cable providing 5v, which then powers the arduino (along with power to momentary pushbottons to reading changes in the pushbutton state) with another branch which will take the power for the LEDs. I'll use MOSFETs to switch the LEDs on and off as arduino nano can only output 100ma whereas each LED and resistor will use 150ma. Max draw on the USB cable will be ~500ma which will work plugging it into a PC usb port or a USB charger.

My thought was if I can get this working well I could look to make a housing for the light and sell them online, I will look at the electronics switching method if I get that far as it seems more reliable and 'propper' than using arduinos.
 

Reloadron

Joined Jan 15, 2015
7,891
Leviton, Gardner Bender and a host of other manufacturers manufacture common off the shelf Push On/Off switches. Here is a single example. I see no mention of voltage and current but for low voltage and current LED lighting I would consider a push On and push again Off common off the shelf switch unless I am missing something? A simple mechanical solution. A Google of push button canopy switch should get a dozen hits or more.

Ron
 

MrSalts

Joined Apr 2, 2020
2,767
Only if you want to buy a programmer than costs much more than a 555 timer, and do the programming. :rolleyes:
Arduino just needs a USB cable.

my comment about the microcontroller was intended as sarcasm but a few people finally came through and suggested it.
i would have used a capacitor-denounced switch to activate a Schmitt Trigger inverter to activate a d-type flip-flop to activate a Mosfet that switches the LED strand.
 
Top