Toggling Lights with a push button

MisterBill2

Joined Jan 23, 2018
27,540
I know that I have seen alternate action push-buttons in a size similar to what I see on that circuit board. I suggest looking at the Digikey catalog site for them .That could be the very simplest option if the current rating is adequate.
 

sghioto

Joined Dec 31, 2017
8,634
That's a nice find. Wonder if that chip or similar might be inside that 4 pin component in the relay module posted in #47.
Thinking a custom housing plus a FET relay driver.
1642007335496.png
 

Thread Starter

teenflon5

Joined Apr 19, 2021
27
So I'm ready to start wiring it up and have followed the suggestions for mosfet and switch wiring which makes sense. In terms of the mosfet resistance, are the numbers used in the diagram correct? Resistance on the load with the LED will be 10 ohm only, does the gate from the arduino need to be less than this resistance?

1642539895871.png
 

Reloadron

Joined Jan 15, 2015
7,891
R5, R6, R7 and R8 should be higher. When S1 through S4 is closed the current on each leg will be about 15 mA. You really don't want that on each DO line. A 10 K resistor is more inline with what you want. You just don't want your DI lines floating. Give this a read.

Ron
 

DC_Kid

Joined Feb 25, 2008
1,242
Might venture into Trinket micro controller. Gives ability to do just about whatever you want in a package just a smidge bigger than a TO220. Button control, touch control, you name it.
 

sghioto

Joined Dec 31, 2017
8,634
The Nano has internal pullup resistor on the inputs that can be activated by code. You can eliminate resistors R5 thru R8 if you rewrite the code for active low on D2 thru D5.
 

eetech00

Joined Jun 8, 2013
4,705
Hello

You won't be able to power the circuit with 5+ using Vin because it is the input to the 5v voltage regulator. The Vin voltage is recommended to be +7vdc or greater.

1642644732998.png
 

sghioto

Joined Dec 31, 2017
8,634
Resistance on the load with the LED will be 10 ohm only, does the gate from the arduino need to be less than this resistance?
Not really. Usually the gates are connected directly to the pins. Adding a 10 ohm or a 1000 ohm wouldn't make any difference on the FET. The 10 ohm resistors on the LEDs should be rated at least 3 watts, 5 watt better.
 

Thread Starter

teenflon5

Joined Apr 19, 2021
27
The Nano has internal pullup resistor on the inputs that can be activated by code. You can eliminate resistors R5 thru R8 if you rewrite the code for active low on D2 thru D5.
This is how I've always done it, but I was told otherwise :) If I remove them that will help save space on my board
 

evbu98

Joined Nov 6, 2019
1
With a flip-flop, you also need a debounce circuit to ignore any contact bounce from the mechanical push-button switch.

LTspice simulation below, of such a circuit using a FF, as mentioned in posts 2 and 3:
R1C1 delays the feedback to the D input (red trace) which prevents more than one output change-of-state (green trace) per button push (as shown by the simulated switch bounces for the first push (yellow trace).

View attachment 239550
So I’m looking through this circuit and I’m just trying to understand it a little better since I have a use case for it.

When the /Q output is high, it should allow for current to flow through R1 and R3 to the Data input. Is the point of the C1 cap only to filter out noise?

also is this push button momentary? Or is it a latching push button?
 

crutschow

Joined Mar 14, 2008
38,515
Is the point of the C1 cap only to filter out noise?
No.
It's to delay the signal to the D input until after any switch-bounce so it doesn't flip-back due to that bounce.
is this push button momentary?
Yes.

But below is a better toggle circuit that uses the other half of the CD4013 FF package to provide debounce on both the press and release of the PB switch (my above circuit only protects against the press bounce).
The left FF is configured to operate as a Schmitt-trigger non-inverting gate.
(If its operation seems a little confusing, note for that FF, the Q output goes high when both the PRE and CLR inputs are high, so the Clk output follows the PRE input.)

1731515391421.png
 
Last edited:

meth

Joined May 21, 2016
304
I did not read all pages of replies, sorry if this solution already appeared in the thread, but just recently I had a task to make an output toggle using only one switch, and this worked just fine:
1731481078224.png
 
Top