# Logic gate counter on 7 segment display

Using logic gates with general purpose transistors, I want to display numbers on a 7-segment display depending on the 2 pushbutton input. If both buttons are not pressed, I want it to say 0. If 1 is pressed, I want it to say 1, if the other one is pressed, I want it to say 2, and if both are pressed, I want it to say 3. I know how to do this with separate LEDs, ( 4 Different  LEDS are lit depending on the switches inputs) ,but I am having troubles figuring this out for a 7-segment display because of the overlapping digits on. I may have done a terrible job explaining this, but any info is helpful.

• is this homwork? Oct 12 '12 at 4:12
• Just write down a truth table... and we could help you understand if and where you're going wrong. Oct 12 '12 at 4:20

I'd do this in 2 steps. First make a circuit that has 4 outputs that correspond to your 0-3 codes. You can test this by hooking common LEDs to the outputs. I believe this is a common decoder circuit.

The second step is to connect the transistors to the LED segments. Place a transistor on each segment. Put power on the collector appropriate for the type of LED. Connect the emitter to a specific segment. The base should be connected to your decoder's outputs.

Say you have an 7-seg LED with segments numbered from 0 to 7. You decide segments 1 and 2 need to be lit for decoder output #0. Connect #0 to the bases of the transistors responsible for segments 1 and 2. Repeat for the other 3 outputs. Where you have different outputs sharing a transistor base, you may need diodes to prevent current from flowing 'backwards' and lighting up segments unexpectedly.

• said differently... the diodes joining to a given net collectively implement an "OR" function on the incoming nets (sort of) in TTL logic... if your decoder stage has 'open collector' outputs, and you use a weak pull-up resistor, you can skip the diodes and you end up with a 'wired-OR' configuration. Oct 12 '12 at 4:22

I'm not sure I can agree with Dean's answer; you can't answer the question "how can I make a BCD-to-7-segment decoder?" with "use a BCD-to-7-segment decoder". His truth table a good start, however. Cut away the bottom part so that you retain a table for the digits 0 to 3:

This shouldn't be too hard. What do we see?

• First thing we notice is that segment $b$ is always on, so that's not a decoded output.
• The codes for column $g$ are the same as the $B$ column.
• Columns $a$ and $d$ are identical.
• Columns $a$, $c$ and $d$ have one 0 and three 1s. That's what the truth table of an OR-gate has. Check which of the inputs you have to invert to make those outputs an OR-function of the (inverted) inputs.
• Similar for column $f$: it has one 1 and three zeros, which an AND-gate will give you. How do you have to change the inputs to use an AND-gate here?
• Columns $e$ can be created from just one input. Which one?

If you can't see the relationships right away, then add two intermediate results, which you derive from the inputs: that's $A$ and $B$ inverted.

Your function table could look like this:

$a = \overline{A} + B$
$b = 1$
$c = A + \overline{B}$
$d = \overline{A} + B$
$e = \overline{A}$
$f = \overline{A} \cdot \overline{B}$
$g = B$

If you think I've done all the work for you, think again. The real work starts now: create a circuit from this using as few gates as possible.

• stevenvh, fair enough. I took the question to be asking for a BCD-to-7 segment decoder without knowing that such a device had a name or existed as a standalone IC. Your answer does a much better job of answering the exact question asked. Oct 12 '12 at 19:53

This can be done with a single BCD decoder IC like the 4511. Connect one pushbutton to input A, and the other pushbutton to input B. Leave C and D disconnected. Reference the the sample circuit below.

Since this is likely homework, however, I'm guessing that you need to do it with discrete logic gates and transistors. I'd start with the following truth table and design your gates from there. I'm sure you can figure out how to drive the transistors so as to sink current out of a common anode display.

The design depends on your goal;

• To learn logic design with Boolean Algebra perhaps with Karnaugh mapping to reduce the solution to simple logic equations... such as stevenh's good explanation

• To implement the design with the fewest parts... such as Dean's solution or a CPLD with stevenh's

• implement the design with easiest way ... depends on your desire to learn new skills, but Boolean Algebra is a must with de Morgan's Law and perhaps Karnaugh mapping are things you should know. It just looks hard at first, but then it becomes really easy to implement any complex requirement of logic once you learn these methods. Firmware solutions with 1\$ PICs become valuable tools for any logic as are CPLD chips. There is always a learning curve on new skills.

• implement the design in the cheapest way for mass production, depends on your budget for time and parts, experience, creativity, tools

• just finish an assignment.. nuf said.

The best answer depends on a well phrased question.