Counter Circuit for LEDs using SN74HC161

Thread Starter

Czexican1329

Joined Apr 23, 2018
57
I am building a counter circuit using a SN74HC161 4-bit binary counter to turn on certain LEDs as the counter counts up. The counter should count up each time the push button is pressed. Is my wiring diagram correct for this application, or am I missing something?Counter Circuit.jpg
 

dl324

Joined Mar 30, 2015
16,935
Welcome to AAC!
am I missing something?
You need a pull-down resistor on the clock input; otherwise it floats when the switch is opened.

You need a switch debounce circuit.

If you care about power dissipation, you shouldn't let the preset inputs float; even if you're not using them.
 

danadak

Joined Mar 10, 2018
4,057
For future reference here is a GUI solution where no user code has to
be written. Example attached. Note no transistors used for LEDs, the
output pins can drive enough current unless you are using high wattage
LEDs.

Tool and Compiler is free, PSOC Creator.

Lots of other capability in part, see attached component list.

Board is $ 4, re-programmable, lots of logic, analog, ARM core if
you decide to do some coding.



Component list attached. A component is on onchip resource in PSOC. PSOC 4 family is a subset of
this list, 5LP family (and its $ 10 board) has virtually all.


Regards, Dana.
 

Attachments

Thread Starter

Czexican1329

Joined Apr 23, 2018
57
Welcome to AAC!
You need a pull-down resistor on the clock input; otherwise it floats when the switch is opened.

You need a switch debounce circuit.

If you care about power dissipation, you shouldn't let the preset inputs float; even if you're not using them.
So I should add a pull down resistor to the CLK input and ground A through D?
And what do I need to do for the switch denounce circuit?
 

AnalogKid

Joined Aug 1, 2013
11,055
In the most simple form, add a capacitor across the pull down resistor. For example, a 47K resistor and 1 uF capacitor combine to have a 50 ms (millisecond) time constant, a good starting point given that we know nothing about the switch or why it is being pushed. Add the two components in parallel between pin 2 and pin 8.

YES, ground pins 3, 4, 5, 6 if they are unused.

ak
 

Thread Starter

Czexican1329

Joined Apr 23, 2018
57
In the most simple form, add a capacitor across the pull down resistor. For example, a 47K resistor and 1 uF capacitor combine to have a 50 ms (millisecond) time constant, a good starting point given that we know nothing about the switch or why it is being pushed. Add the two components in parallel between pin 2 and pin 8.

YES, ground pins 3, 4, 5, 6 if they are unused.

ak
 

Thread Starter

Czexican1329

Joined Apr 23, 2018
57
The circuit is being used to change the color of an RGB LED each time a push button is pressed. The voltage source is 5V. What values should I use for the resistor and capacitor?
 

Thread Starter

Czexican1329

Joined Apr 23, 2018
57
One final question, is it possible to make the counter reset itself so that the LED turns off once it cycles through all of the colors?
 

dl324

Joined Mar 30, 2015
16,935
One final question, is it possible to make the counter reset itself so that the LED turns off once it cycles through all of the colors?
What do you mean by reset? The LEDs will cycle through 8 different combinations endlessly. One of those combinations is all LEDs off.
 

Thread Starter

Czexican1329

Joined Apr 23, 2018
57
What I meant was, at first, the LED should be off, then once the button is pressed, it turns on, and the color changes with each pressing of the button. Once the last color/count is reached, pressing the button should turn the LED off. Pressing it again after it has turned off should turn the LED back on, allowing you to cycle through the combinations. The problem I'm having right now is that the counter is counting up once power is applied to the circuit before the push button has been pressed.
 

dl324

Joined Mar 30, 2015
16,935
The problem I'm having right now is that the counter is counting up once power is applied to the circuit before the push button has been pressed.
Well, that isn't what you said in post #15.

You need to have a power on reset on CLR if you want to force the counter to power up with a count of 0. You can use a resistor and capacitor to hold CLR low when power is first applied.
 

Thread Starter

Czexican1329

Joined Apr 23, 2018
57
Well, that isn't what you said in post #15.

You need to have a power on reset on CLR if you want to force the counter to power up with a count of 0. You can use a resistor and capacitor to hold CLR low when power is first applied.
Oh! Thank you!
 
Top