User Tools

Site Tools


electronics:buttons

Buttons

A button, also called as switch, is an electric component that can break an electrical circuit by interrupting the current.

When used in schematics, these are the possible symbols:

This is an example of circuit that uses a switch:

When the button is pressed, it acts like a wire and it will let the current flow through the circuit. If the button is not pressed, the circuit is interrupted.

When a button is connected to a board, we can say if the button was pressed by looking at the pin's value.

Let's see how we can connect a button to Raspberry Pi. The first possibility is this, but it is wrong:

Why is it wrong? If the button is pressed, everything works fine. The value of pin would be HIGH and we can say “Yes, the button is definitely pressed”. But what happens when the button is off? It is important to know that a logic level can be: LOW (or 0), HIGH (or 1) and also UNKNOWN (or high impedance). When the button is not pressed we can't say for sure what logical level the pin has: it could be 0 as well as 1 because the wire isn't connected neither to Ground nor to a power supply.




Let's give it another try. How about this one?

No! Don't try this one! It will destroy your Raspberry Pi. When the switch is off the button's pin value is HIGH. The big problem appears when the button is pressed. It will create a short circuit: the ground is directly connected to VCC which is very bad because we don't have any resistor and the electric current isn't limited.





The correct way to connect a button to a board is like this:

Now we won't have a short circuit if the button is pressed because we have the R resistor. The R resistor is called a pull up resistor. If the button is pressed our pin's value will be LOW.

electronics/buttons.txt · Last modified: 2014/01/16 18:27 by bogdan.vlad