Electronic – Using two switches to light/turn off consecutive LEDs

ledswitches

I am trying to create a circuit that controls 10 LEDs with two momentary switches. Let's call one button ButtonUp and the other ButtonDown.

When I press ButtonUp, the first LED lights up. If I hit ButtonUp again, the second LED lights up, etc., resulting in all LEDs being lit if you hit ButtonUp 10 times.

If I press ButtonDown, the most recently lit LED turns off.

  • Is there a way to do this with a circuit and if so, how?

  • Is this a job better-suited for a programmable chip like the one found in an Arduino?

Best Answer

You can take several approaches to this depending on your ulterior motives. E.g. Are you approaching this as a beginner level learning experience in logic design, microprocessors or FPGAs? Or, perhaps, this will have some sort of product application?

This can be done using 7400 family logic with a handfull of chips. The centerpiece would be a decade up-down counter ( e.g. 74x168 or 74x192) or a binary up-down counter ( e.g. 74x169 or 74x193. The output of this counter would go to a 1:n decoder chip of some sort (e.g. 74x145). This in turn would drive the LEDs in a "chain" so you would get the histogram effect you are looking for. The pushbuttons would need to be "conditioned" by some logic to get the up-down pulses converted to a direction and clock format needed by the counter you choose. It can definitely be done, but you will need to apply a moderate dose of ingenuity. You'll certainly have learned a lot about logic design by the time you are done!

Another logic approach would be to use a 10-bit bi-directional shift register (probably two 8-bit units wired in series like 74x299 or 74x323). You would "pump" a 1-bit up and down the shift register with the push buttons (again "conditioned" to provided the format of signals needed by the specific shift register you choose). The 1 bit would propogate as a string of 1-bits thru the stages of the shift register - growing as you shift right, shrinking as you shift left. The LEDs would be driven directly from the shift register outputs. This approach is probably simpler to implement than the counter approach described above. Again, an excellent beginner level project to learn fundamental logic design.

Performing this function with a small micro is almost trivial - assuming you have a fundamental level of design experience with such devices. If you don't, it would be a good beginner level micro project.

Lastly, and depending on your background, you could use an FPGA ( "field programmable gate array" ) or CPLD ( "complex programmable logic device"). This would be the most elegant solution in terms of minimal parts count. It would be the FPGA chip, the buttons, and the LEDs and not much else. The downside is assembling the required design tools and learning to use them. Plus, you'd probably have to learn the VeriLog or VHDL FPGA programming design language. This is a tall wall to climb for beginners. Especially if you don't know much about fundamental logic design to begin with.

In summary, it depends on where you're coming from, and where your headed.

Good Luck!