택트 스위치와 풀업·풀다운 저항Tact Switches and Pull-Up/Pull-Down Resistors
디지털 입력이 떠다니지 않게 하는 풀업·풀다운 저항의 원리와 값 선택, 4핀 택트 스위치의 내부 연결, 채터링(바운스)을 설명합니다.How pull-up and pull-down resistors keep a digital input from floating, how to choose their values, the internal connections of a 4-pin tact switch, and contact bounce.
스위치를 디지털 입력 핀에 연결할 때 가장 흔한 실수는 스위치 한쪽만 입력 핀에, 다른 쪽은 접지에 달고 끝내는 것입니다. 스위치를 눌렀을 때는 Low가 되지만, 누르지 않았을 때 입력 핀은 어디에도 연결되지 않은 "떠 있는(floating)" 상태가 되어 High와 Low를 오가며 엉뚱하게 동작합니다. 이 문제를 풀업·풀다운 저항이 해결합니다. 이 글에서는 풀업·풀다운의 원리, 저항값 고르기, 4핀 택트 스위치의 내부 연결, 채터링(바운스)과 대처법을 설명합니다.
입력 핀이 떠 있으면 생기는 일
CMOS 입력 핀은 임피던스가 매우 높아 주변 잡음(손가락 근처, 인접 배선의 신호)만으로도 전압이 변합니다. 아무것도 연결하지 않으면 출력이 무작위로 바뀌거나, 중간 전압에 머물러 IC가 불필요한 전류를 흘립니다. 입력 핀은 항상 High나 Low 중 하나로 확실히 연결되어 있어야 합니다.
풀업과 풀다운
풀업은 저항으로 +V에, 풀다운은 저항으로 GND에 입력 핀을 묶어 둡니다.
풀업 저항: 입력 핀을 저항을 거쳐 +V에 연결합니다. 스위치는 입력 핀과 GND 사이에 둡니다. 누르지 않으면 High, 누르면 GND로 당겨져 Low가 됩니다.
풀다운 저항: 입력 핀을 저항을 거쳐 GND에 연결합니다. 스위치는 입력 핀과 +V 사이에 둡니다. 누르지 않으면 Low, 누르면 High가 됩니다.
디지털 회로에서는 풀업 방식이 더 널리 쓰입니다. 접지에 연결하는 스위치는 배선이 쉽고, 많은 마이크로컨트롤러가 내부 풀업 저항을 제공하기 때문입니다.
저항값 고르기
값
특징
1kΩ ~ 4.7kΩ
빠르고 잡음에 강하지만 누를 때 전류가 큼(5V에서 1~5mA)
10kΩ
가장 흔한 선택. 누를 때 전류 0.5mA
47kΩ ~ 100kΩ
전류 소모가 적어 배터리 회로에 알맞지만 잡음에 약함
스위치를 눌렀을 때 저항을 통해 전원 전압 ÷ 저항 만큼의 전류가 흐릅니다(5V, 10kΩ이면 0.5mA). 입력 핀의 누설 전류보다 충분히 커야 하므로 너무 큰 저항(수 MΩ)은 피하세요. I2C처럼 신호가 빠르게 변하는 선은 풀업 값이 속도에 영향을 줍니다(I2C 배선 기초).
4핀 택트 스위치의 내부 연결
같은 쪽 두 핀은 이미 연결되어 있고, 버튼을 누르면 위쪽 쌍과 아래쪽 쌍이 연결됩니다.
작은 누름 스위치(택트 스위치)는 핀이 네 개이지만 접점은 하나입니다. 몸체의 한 변에 있는 두 핀은 내부에서 항상 이어져 있고, 버튼을 눌러야 맞은편 쌍과 연결됩니다.
대각선에 있는 두 핀(예: 1번과 4번)을 쓰면 방향을 헷갈려도 항상 올바른 접점이 됩니다.
같은 변의 두 핀만 쓰면 누르지 않아도 항상 연결된 상태라서 스위치가 고장 난 것처럼 보입니다.
방향이 헷갈리면 멀티미터를 도통 모드로 놓고 핀 쌍을 확인하세요. 누르지 않았을 때 울리는 쌍이 같은 변입니다.
패턴도의 택트 스위치(소 3×4칸, 대 4×4칸)도 긴 쪽 두 핀을 서로 연결해 두고 짧은 쪽이 눌림 접점이 되도록 실제 부품처럼 모델링되어 있습니다.
채터링(바운스)
기계식 스위치는 접점이 붙을 때 몇 ms 동안 여러 번 붙었다 떨어지기를 반복합니다. 사람 눈에는 한 번 누른 것이지만, 빠른 디지털 회로는 수 번 눌린 것으로 읽습니다. 카운터에 연결하면 한 번 눌러도 숫자가 여러 번 올라가는 이유입니다.
해결 방법은 세 가지입니다.
소프트웨어: 값이 바뀐 뒤 10~20ms 동안 입력을 무시합니다. 마이크로컨트롤러에서 가장 쉽습니다.
SR 래치: 접점이 두 개인 스위치(SPDT)를 NAND 두 개로 만든 래치에 연결하면 첫 접촉만 반영됩니다.
DIP 스위치와 슬라이드 스위치
DIP 스위치는 작은 스위치 여러 개를 한 몸체에 모은 부품으로, 한 번 설정해 두는 값(주소, 모드)을 입력할 때 씁니다. 각 스위치의 한쪽을 풀업(또는 풀다운) 저항과 입력 핀에, 다른 쪽을 GND(또는 +V)에 연결하는 구성은 택트 스위치와 같습니다. 패턴도의 4채널 DIP 스위치는 클릭해서 ON/OFF를 바꿔 가며 시뮬레이션에서 입력 변화를 확인할 수 있습니다. 이를 활용한 예제는 DIP 스위치로 숫자를 고르는 7세그먼트 표시기에 있습니다.
정리
디지털 입력은 풀업이나 풀다운으로 항상 확실한 레벨을 줘야 하고, 값은 보통 10kΩ입니다. 택트 스위치는 대각선 핀을 쓰는 것이 안전하며, 버튼에서 오는 떨림은 소프트웨어나 RC 필터로 처리합니다. 이어서 74LS·74HC 로직 게이트 기초에서 쓰지 않는 입력을 처리하는 방법을 보세요.
The most common mistake when connecting a switch to a digital input pin is to wire one side of the switch to the input pin and the other to ground and stop there. When the switch is pressed the pin goes Low, but when it is not pressed the input pin is connected to nothing, in a "floating" state, and swings between High and Low and behaves erratically. Pull-up and pull-down resistors solve this problem. This article explains the principle of pull-ups and pull-downs, how to choose the resistance, the internal connections of a 4-pin tact switch, and contact bounce and how to deal with it.
What happens when an input pin floats
A CMOS input pin has a very high impedance, so its voltage changes with just surrounding noise (near a finger, signals on adjacent wiring). If nothing is connected, the output changes randomly, or it sits at an in-between voltage and the IC draws needless current. An input pin must always be firmly connected to either High or Low.
Pull-up and pull-down
A pull-up ties the input pin to +V through a resistor, and a pull-down ties it to GND through a resistor.
Pull-up resistor: connects the input pin to +V through a resistor. The switch goes between the input pin and GND. When not pressed it is High, and when pressed it is pulled to GND and becomes Low.
Pull-down resistor: connects the input pin to GND through a resistor. The switch goes between the input pin and +V. When not pressed it is Low, and when pressed it becomes High.
In digital circuits, the pull-up approach is more widely used. A switch to ground is easy to wire, and many microcontrollers provide internal pull-up resistors.
Choosing the resistance
Value
Characteristics
1 kΩ – 4.7 kΩ
Fast and robust against noise, but the current when pressed is large (1–5 mA at 5 V)
10 kΩ
The most common choice. 0.5 mA when pressed
47 kΩ – 100 kΩ
Low current draw, suited to battery circuits, but weak against noise
When the switch is pressed, a current of supply voltage ÷ resistance flows through the resistor (0.5 mA for 5 V and 10 kΩ). It has to be well above the leakage current of the input pin, so avoid resistors that are too large (several MΩ). On lines whose signal changes quickly, like I2C, the pull-up value affects the speed (I2C Wiring Basics).
Internal connections of a 4-pin tact switch
The two pins on the same side are already connected, and pressing the button connects the upper pair with the lower pair.
A small push switch (tact switch) has four pins but only one contact. The two pins on one side of the body are always connected inside, and only when you press the button do they connect to the opposite pair.
If you use two pins on a diagonal (for example, pin 1 and pin 4), it is always the right contact even if you mix up the orientation.
If you use only two pins on the same side, they are always connected even when not pressed, so the switch looks broken.
If you are unsure of the orientation, set the multimeter to continuity and check pairs of pins. The pair that beeps when not pressed is the same side.
The tact switch in Patterndo (small 3×4 holes, large 4×4 holes) is also modeled like the real part, with the two longer-side pins connected together and the shorter side as the pressed contact.
Contact bounce
A mechanical switch's contacts make and break several times for a few ms when they close. To the human eye it is one press, but a fast digital circuit reads it as several presses. This is why, when connected to a counter, the number goes up several times with one press.
There are three fixes.
Software: ignore the input for 10 to 20 ms after the value changes. This is the easiest on a microcontroller.
RC filter + Schmitt trigger: put a resistor and capacitor on the switch pin (for example, 10 kΩ and 100 nF → a 1 ms time constant) and feed it into a Schmitt trigger input (such as a 74HC14), and the jitter is filtered (Understanding RC Time Constants and Capacitor Charging).
SR latch: connect a switch with two contacts (SPDT) to a latch made from two NAND gates, and only the first contact is reflected.
DIP switches and slide switches
A DIP switch gathers several small switches in one body and is used to enter values you set once (addresses, modes). The arrangement is the same as with a tact switch: one side of each switch goes to the pull-up (or pull-down) resistor and the input pin, and the other to GND (or +V). The 4-channel DIP switch in Patterndo can be clicked to toggle ON and OFF, so you can check input changes in simulation. An example using it is in A Seven-Segment Display Selected with a DIP Switch.
Summary
A digital input must always be given a firm level with a pull-up or pull-down, and the value is usually 10 kΩ. For a tact switch, using the diagonal pins is safest, and jitter from a button is handled by software or an RC filter. Next, see how to handle unused inputs in 74LS and 74HC Logic Gate Basics.
에디터에서 직접 해 보기Try it in the editor
읽은 내용을 패턴도 에디터에서 바로 확인해 보세요. 회원가입 없이 열리고, 납땜 전에 배치와 배선을 몇 번이고 고쳐 볼 수 있습니다.Try what you just read right in the Patterndo editor. It opens without sign-up, and you can rework the layout and wiring as many times as you like before you solder.
이 글은 학습 목적의 일반적인 안내입니다. 부품마다 규격과 핀 배열이 다를 수 있으니 실제 작업 전에는 사용하는 부품의 데이터시트를 확인하세요. 안전과 관련된 작업은 항목별 주의 사항을 먼저 읽고 진행하세요.This article is general guidance for learning purposes. Specifications and pinouts differ between parts, so check the datasheet of the part you use before real work. For safety-related work, read the cautions for each item first.