Logic Gates SOLVED

Here is an example of an AND gate with attached to switches. While one switch is open and another closed, it generates the logical output (but should not). Can anyone lend any assistance?

by kevbot89
May 30, 2017

2 Answers

Answer by Garrett

Try adding a pull down resistor after each button. Or you could replace the buttons with a SPDT switch and use 5V and Gnd as the inputs and feed that into the and gate. Its because when the button isn't pressed there is no input to the AND gate so its undefined.

ACCEPTED +4 votes
by Garrett
June 02, 2017

Answer by mrobbins

@Garrett's answer is exactly right! Pull-down resistors would help here. Here's your circuit with pull-down resistors added:

(Click the circuit, click "Simulate", then "Run DC Solver." The output is now 0 as you expect!)

FYI, this is not just a simulation issue. It's potentially a real-world issue too, with different types of digital logic making different assumptions if an input is left "floating" (unconnected). It's always good practice to add an explicit pull-down or pull-up resistor. Sometimes, for example in many microcontrollers or other embedded systems like the Arduino and Raspberry Pi, these internal pull-up resistors and pull-down resistors can be turned on by software.

Another way to test out the AND gate is just to use digital clocks as your inputs, which always supply a solid logical 0 or 1:

(Click the circuit, click "Simulate", then "Run Time-Domain Simulation." This shows all four combinations of inputs for the AND gate.)

+2 votes
by mrobbins
June 02, 2017

Your Answer

You must log in or create an account (free!) to answer a question.

Log in Create an account


Go Ad-Free. Activate your CircuitLab membership. No more ads. Save unlimited circuits. Run unlimited simulations.

Search Questions & Answers


Ask a Question

Anyone can ask a question.

Did you already search (see above) to see if a similar question has already been answered? If you can't find the answer, you may ask a question.


About This Site

CircuitLab's Q&A site is a FREE questions and answers forum for electronics and electrical engineering students, hobbyists, and professionals.

We encourage you to use our built-in schematic & simulation software to add more detail to your questions and answers.

Acceptable Questions:

  • Concept or theory questions
  • Practical engineering questions
  • “Homework” questions
  • Software/hardware intersection
  • Best practices
  • Design choices & component selection
  • Troubleshooting

Unacceptable Questions:

  • Non-English language content
  • Non-question discussion
  • Non-electronics questions
  • Vendor-specific topics
  • Pure software questions
  • CircuitLab software support

Please respect that there are both seasoned experts and total newbies here: please be nice, be constructive, and be specific!

About CircuitLab

CircuitLab is an in-browser schematic capture and circuit simulation software tool to help you rapidly design and analyze analog and digital electronics systems.