0
\$\begingroup\$

When use switchstrong text

We know when use switch easy for us to state input logic.

Logic 1 means input connected to positive terminal.

Logic 0 means input connected to negative terminal.

How about unconnected input from anywires?

It will be problem when use pushbutton as input.

I want when unpushed button the state input will be 0. When button pushed, the state input will be 1.

But the problem is when button unpushed, the input state will "unconnected to any wires" which we can't say it as 0 state due to 0 state means connected to groundenter image description here

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Pull-down resistor 10k or 100k will do. (Also add a LED driving resistor, like 330R) \$\endgroup\$
    – user16324
    Dec 5, 2020 at 15:26
  • 1
    \$\begingroup\$ @BrianDrummond if that really is a 7404 or other bipolar device like 74LS04 the pull down would have to be considerably stronger. For a 74HC04 or other CMOS device it would work though. \$\endgroup\$
    – Justme
    Dec 5, 2020 at 15:29
  • \$\begingroup\$ @Justme Somehow I read it as 74HC04 ... wrongly. You are correct. \$\endgroup\$
    – user16324
    Dec 5, 2020 at 15:34

2 Answers 2

2
\$\begingroup\$

This is the job of what's called a pull-up resistor (or a pull-down resistor, depending on how you're using it). The circuit you should use looks like this:

schematic

simulate this circuit – Schematic created using CircuitLab

The left one is using a pull-down resistor, and will read logic low (0 for active-high logic) whenever the switch is not pressed, and will read logic high when it is. The right one is the opposite, using a pull-up resistor; this reads logic high (1 in active-high logic) when the switch is not pressed, and logic low when it is.

You'll need one resistor for each input, but if that sounds like too much, you can get resistor networks that have many resistors in a single package, and some logic chips have internal pull-up or pull-down resistors; check your datasheet. If you're using a microcontroller, most of those allow you to configure their inputs to use an internal pull-up or pull-down resistor; look at your μC's datasheet for information on this. It's usually as simple as setting bits in a register somewhere.

The exact value of the resistor doesn't matter that much. The lower the resistor, the faster it can charge or discharge the input capacitance, but this only really matters when dealing with things that actuate much faster than pushbuttons, like an I²C bus. But also, the lower the resistor, the higher the current will be when the switch is pressed, so you don't want it too low. Somewhere in the range of 1kΩ to 100kΩ usually works fine.


A note since you're using a 7404 specifically: the 7404, as well as the 74LS04, has internal pull-up circuitry, so you don't need any resistors if you put your pushbutton between the input and ground. An unconnected input will be read as high.

The presence of this internal pull-up also means that if you want a pull-down, you're going to need to use a small resistor value since you'll be forming a voltage divider.

Note that the 74HC series, unlike most 74 variants, does not have internal pull-ups, so if your chip is actually a 74HC04 you will need an external resistor.

\$\endgroup\$
2
  • \$\begingroup\$ Thank you very much, your answer is more than i expect. How about double pull resistor? I mean both of your picture has combined and we got two resistor, the one near VCC the one near GROUND (both resistors have same value)? And we put push button whatever we want for example near VCC. What kind that resistor? \$\endgroup\$ Dec 5, 2020 at 16:41
  • \$\begingroup\$ That would be a voltage divider, and wouldn't do anything useful for logic circuitry but is very useful for analog electronics. \$\endgroup\$
    – Hearth
    Dec 5, 2020 at 17:26
1
\$\begingroup\$

Typically a resistor is used for keeping the input at logic high level, and pushbutton to connect the input to ground.

\$\endgroup\$
5
  • \$\begingroup\$ Will it affect to other input? That concept looks like making circuit short if without resistor, right? \$\endgroup\$ Dec 5, 2020 at 15:42
  • \$\begingroup\$ Which other input? And why would one input affect other inputs? \$\endgroup\$
    – Justme
    Dec 5, 2020 at 15:43
  • \$\begingroup\$ in this case yeah i just put one input (A). But what if other input? \$\endgroup\$ Dec 5, 2020 at 15:46
  • \$\begingroup\$ Set it to any value you want if the output does not matter. \$\endgroup\$
    – Justme
    Dec 5, 2020 at 15:50
  • \$\begingroup\$ Thank you very much, i know now... The concept is like make a short circuit when button has pushed. U know im computer engineer student.. i dont need know more about electronic. And in digital we must know about it. So i just need know when it's ON (1) and when it's OFF (0) also logic gates using transistor. Thanks \$\endgroup\$ Dec 5, 2020 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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