# Circuit to keep two LEDs on when buttons are released

I am trying for the first time to build something on my own. I am pretty n00b when it comes to electronic so, please, bear with me.

I'm trying to build a "simple" schematic that goes like this: there are two buttons (SW1 and SW2) normally open, and 2 LEDs (D2 and D3) associated to each button. When a button is closed, the relative LED turns on, but when button is released, the relative LED shall continue to stay on.

One button shall not influence the other LED.

In addition, there is a third button Reset button which is used to turn off both the LEDs: while it's pressed, the Reset button will turn off the LEDs.

To do this (apparently) simple circuit, I am using some gates:

• a NOT gate which inverts the reset button: when button is not pressed, the gate shall be high and enter two AND gates.
• two AND gates which take the reset as one input. When reset is pressed (+Vcc), the NOT gate should go low, making the AND gates to go low in output. The other input of the AND gates is the output of two OR gates (one-to-one).
• the OR gates (OR1, OR2) use a feedback mechanism to keep high the signal once it goes high. Each OR has SW1 (SW2) and the output of the AND gates (AND1, AND2) as input. When reset is pressed and no button is pressed, the OR goes low, but if one button is pressed and no reset is pressed, then the output is high, which goes in the AND port, which shall output high and thus keeping the OR gates high.

I realized on a breadboard the circuit below

simulate this circuit – Schematic created using CircuitLab

Sorry, in the image some resistors are wrong: R5 = R3 = R1 = 5.6k Ohm R6 = R7 = 10k Ohm

I used 74LS04 for the NOT gate, 74LS08 B1 for the AND gates and 74LS32 for the OR gates.

Being LS, I connected all the unused input to ground, while every other input shall be connected, because I tried to use pull-down resistors on the inputs.

Now, this is the first time I try something this complex: I know this is conceptually simple, but I just don't have the tools and knowledge to deal with the hardware fabrication.

In fact, this circuit is not working as I was expecting: even if the reset button is not pressed (or even if it is pressed), the NOT gate will always produce an output voltage of 0.75, which is (I think) low. In fact, the SW1 and SW2 buttons will just turn on the LEDs when they are closed.

If I remove the link that goes from the NOT gate to the AND gates, leaving only the D1 LED as output, the NOT gate works as expected.

As additional input: the chips are connected properly to Vcc and GND (+5V and 0), and I am using, as a power source, a stabilized power supply (that is actually a recycled computer PSU).

Well, that's all for now... Can someone give me an advice? I can't really understand what's happening (and why).

• 10k seems like a lot of resistance for R2, R6, R7, are you sure this is an appropriate value? – kjgregory Jul 24 '14 at 17:34
• @KGregory, no, I am not sure at all! I don't even know how to calculate the right values :( – AkiRoss Jul 24 '14 at 17:35
• LED resistor calculation: electronics.stackexchange.com/questions/25222/… – kjgregory Jul 24 '14 at 17:37
• Do you have to build your own latches, or can you use a R-S latch as a building block? BTW, it's much more common to see pull-up resistors and LEDs permanently connected to the power rail, and switches and gates providing the low side. – Ben Voigt Jul 24 '14 at 22:18
• I don't have to build my own latches, and in fact I have some SR latches (74LS279) which I can use, but I didn't thought thoroughly about how to use them to achieve the same I/O – AkiRoss Jul 25 '14 at 6:23

## 2 Answers

The concept looks sound.

The main thing I see is that your 5.6K resistor is way too high to guarantee a low level for a 'LS04. The 100 ohm resistors you used elsewhere are okay (but they'll get warm if the switch is held).

Suggest you use ~150 ohms for the pull down resistors and maybe 4.7K for the LED resistors.

It would be better to use a spare inverter for each of the LEDs (so the output is low for LED 'on') and connect the LED + resistor between Vcc and the output. That's because you're loading the outputs with the LED and TTL can't source current that well. Then you can use 470 ohms or even less for the LEDs and they'll be much brighter.

• Are 330 also Ok? – AkiRoss Jul 24 '14 at 17:36
• Using 330 ohm resistor worked!! :D Thanks so much! – AkiRoss Jul 24 '14 at 17:39
• Yes, 330 * 0.4mA maximum input current is 132mV, easily good enough. – Spehro Pefhany Jul 24 '14 at 17:41
• Thanks a lot, also for your tip about using the inverters – AkiRoss Jul 24 '14 at 17:44
• I've read this many places. Is an inverter not considered TTL like the other logic gates? Also, are inverters typically designed to be used as buffers and consequentially typically have greater fanout and output current provisions? – sherrellbc Jul 24 '14 at 19:35

Although you have already selected Spehro's answer, I thought you ought to learn a little about using LS series ICs.

LSTTL, like regular TTL, has an input which is essentially an NPN transistor with the emitter exposed. It also has an output which, while it can drive both high and low, is much stronger pulling low than driving high. This makes sense, since the inputs for this family require a good deal more current to go low than they do to go high.

As a result, you should not use pull-down resistors on inputs. Use pull-ups. Likewise, if you are using switches as inputs, tie them to ground, and use a pull-up resistor. Spehro has mentioned about driving LEDs by pulling them down, rather than trying to force them high. With this in mind, your circuit ought to look like this

simulate this circuit – Schematic created using CircuitLab

Note that the reset switch does not need a dedicated pull-up resistor, the LED serves the purpose.

And, if you think about it, the circuit can be simplified further:

simulate this circuit

The only potential drawback to the simplified version is the requirement that the LED current be within the spec for low output current. If you try to draw too much current, the voltage at the other gate input may be too high for proper operation. In the case of the 74LS00 http://www.ti.com/lit/ds/symlink/sn74ls00.pdf, the recommended max low output current is 16 mA.

• This is really helpful and informative, thanks a lot! – AkiRoss Jul 24 '14 at 19:15
• You're entirely welcome. And, just to complicate your life further, you should be aware that almost nobody uses LSTTL any more. If you want to do discrete logic, CMOS (such as the 74HC series) is the current king. It's just as fast and takes less power. When using CMOS, the preference for pull-up/pull-down goes away. You can use whichever you like. – WhatRoughBeast Jul 24 '14 at 19:44