Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
    
The solution will be dramatically different with, say, TTL components versus a microcontroller. It would be easier with a microcontroller and use fewer components. However if you want to learn CMOS or TTL or something, then go that route. –  JYelton Feb 26 at 22:25
    
If you push ButtonUp 10 times, how many LEDs are lit? One (just the top one) or 10 (all of them)? –  Spehro Pefhany Feb 26 at 22:32
    
If you press ButtonUp 10 times, all 10 LEDs would be lit. –  user37866 Feb 26 at 22:36
    
@JYelton I am a little more familiar with CMOS/TTL than microcontrollers, but I've never had any real formal training with either. –  user37866 Feb 26 at 22:39
add comment

3 Answers 3

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!

share|improve this answer
3  
Why would a microcontroller-based solution have any more parts than an FPGA-based one? –  Dave Tweed Feb 26 at 23:53
    
Most FPGAs need a configuration EEPROM, so I can't see it being simpler. CPLD, maybe. –  Spehro Pefhany Feb 27 at 1:42
    
Thanks for the suggestions. I think I've got my head around using a up/down counter and decoder chip, but from my understanding, using the decoder chip would just turn on the LED corresponding to the number the counter is at, not all the LEDs below. I know I could just set up a chain of OR logic gates to light up the other LEDs, but is there a more elegant way to accomplish that? –  user37866 Feb 27 at 15:25
    
I don't know if it is more elegant but the LEDs could be in series with a point between each of them, that when grounded, turns on all LEDs above that point. The current limiting resister would be different at each point because each point controls a different number of LEDs. It is kind of a wired-OR. –  George White Feb 27 at 21:14
add comment

It could be done with a few HCMOS chips (for example, one 74HC14, one 74HC00 and three 74HC194) and a reset chip (up to 12 LEDs).

Parallel load at power up, and shift 0's or 1's in left or right to turn the LEDs on or off. Needs debouncing and left/right setup time delays, so a few discrete parts.

It would be easier to use a microcontroller once you've gotten over the learning curve. The only hardware required might be a microcontroller with enough port pins, the LEDs and some resistors.

share|improve this answer
add comment

If you decide to use medium scale integration digital logic, one option is to build it around three, 4-bit, bidirectional shift registers. One part is the 74HC194. It has separate data-in pins for shifting right and shifting left. If one data-in pin is tied high and the other tied low you can shift one's in from (lets say) the left, towards the right. The ones will propagate to the right. If each LED is driven from an output pin you get the desired result. When you shift from the right, zeros will shift in, driving the ones out to the left.

You will need a circuit to cause a clock when either button is pressed but have the mode pins depend upon which button was pressed. You could OR the buttons to have either trigger a 555 to emit a pulse, with the trailing edge of the pulse being the shift register clock. That will also debounce the button. If the buttons also separately go to the set and reset, respectively, of a Set/Reset FF, the Q and Q bar outputs of the flop can drive the S0 and S1 mode pins.That will make one button the up and the other the down. Also you will need to do something to reset the shift register on power up. The 74HC194 has a master reset that should make that easy to do.

share|improve this answer
    
I didn't see the very similar answers before I posted. –  George White Feb 26 at 23:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.