How To: Connecting a Switch or Button
Last Modified: 2006-07-21
find:

basket

Acroname Robotics PDF webpage version How To: Connecting a Switch or Button PDF

Related
Products

Product image for SPDT Toggle Switch
SPDT Toggle Switch

A simple switch has an open state and closed state.  However, a microcontroller needs to see a definite high or low voltage level at a digital input.  A switch requires a pull-up or pull-down resistor to produce a definite high or low voltage when it is open or closed.

A resistor placed between a digital input and the supply voltage is called a "pull-up" resistor because it normally pulls the pin's voltage up to the supply.  A switch placed between the digital input and ground will short the digital input to ground when it is pressed.  This means the voltage seen at the input will be high when the switch is open and low when the switch is closed.

A resistor placed between a digital input and ground is called a "pull-down" resistor because it normally pulls the pin's voltage down to ground.  A switch placed between the digital input and the voltage supply will short the digital input to the voltage supply when it is pressed.  This means the voltage seen at the input will be low when the switch is open and high when the switch is closed.

A pull-up or pull-down resistor can be quite large and still work properly.  Values from 1K to 10K are typical.  Some typical switch circuits are shown below. 

Two examples of push button circuits. Left circuit is a pull down. Right circuit is a pull up.
Sample push-button circuits.
 
 
voice: 720-564-0373, email: sales@acroname.com, address: 4822 Sterling Dr., Boulder CO, 80301-2350, privacy
© Copyright 1994-2008 Acroname, Inc., Boulder, Colorado. All rights reserved.