Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Simple and gate

Status
Not open for further replies.

AtomSoft

Well-Known Member
Ok i want to make a simple AND gate and just want to make sure im not going nuts...

Would the attached image be ok to use?

I assume being pulled low the signal stays low... and only until both buttons are pressed it stays low. When both pressed at same time it goes high... Correct?
 
That won't work. When S1 closes, the output, independent of S2, will be 4.3V. When S2 is closed, it will have no effect on the output, independent of the state of S1.
Attached is a circuit that will work.
If you want a NAND gate, remove Q3 and R2, and take the output from the collector of Q1.
 
Last edited:
If you have a regulated 5v supply you can do it with one transistor, with a resistor in series with each button and a pullup resistor from base to 5v, the base will only <0.6v if BOTH buttons are pressed. (buttons connect to ground).

The output at the collector needs a pullup to 5v.
 
Hi,

Geeze guys :)

If you have two *switches* you've got half the battle won because they are active devices too.

Wire the two switches in series, then wire the resistor in series with the two switches so that everything is in series.
Tie the loose end of the last switch to +5v, tie the loose end of the resistor to ground.
Take the output from the junction of the switch and resistor. The output only goes high when both switches are closed.
To make a NAND, tie the resistor to +5 and the loose end of the last switch to ground, take the output from the junction of the resistor and first switch. The output only goes low when both switches are closed.

Two switches, one resistor, zero transistors.
 
Last edited:
Good one! :)

It definitely wins the low parts count competition, but does it really qualify as an "AND" gate? To me that requires two parallel inputs, ie a circuit that could be run from two buttons, OR two other 1pin logic signal sources.

Of course by the strict definition of that a 1 transistor "AND gate" is really an AND gate with two inverted inputs, or one inverted output, depending how it is wired. However an output inversion is less critical as I suspected Atom wanted to get two parallel inputs to activate a single microcontroller input. Atom please correct me if that was wrong.
 
Hi,

Strictly speaking it is not an AND 'gate' but it does provide the AND 'function' using two switches, and that is what he appeared to want since he posted two 'buttons' and he had accepted another design using switches too.

If he really does change this where we instead wants a true AND 'gate' to work with signals instead of switches, then we'll have to resort to two diodes and a resistor :)
 
Yep that's a standard but can have issues due to the micro input being a schmidt trigger, usually switching at setpoints about 0.2Vdd (1v) and 0.8Vdd (4v).

Using the transistor essentially negates that large hysteresis and means the input signals will be much easier to set up to reliably give the result that when both inputs are high the micro input is <1v and when either or both inputs are low the micro input is >4v.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top