Switches and push buttons: Difference between revisions
From wikiluntti
| Line 1: | Line 1: | ||
== Introduction == | == Introduction == | ||
See more different switches at https://learn.sparkfun.com/tutorials/button-and-switch-basics/all | |||
== Theory A: Simple switch == | == Theory A: Simple switch == | ||
Revision as of 16:26, 23 July 2023
Introduction
See more different switches at https://learn.sparkfun.com/tutorials/button-and-switch-basics/all
Theory A: Simple switch
Theory B: Push Button

A double pole single throw push button micro switch (DPST) is a widely used button. Push button switches are often color coded to indicate their function.
Three methods to wire
- External pullup or pulldown resistor: Use
pinMode( Button_pin, INPUT);in the setup. - Internal resistor (20k-50k Ω): Use
INPUT_PULLUPin setuppinMode( Button_pin, INPUT_PULLUP);. The default value isHIGH(1) and by pressing the button the state goes toLOW. - The bad method: Use
pinMode( Button_pin, INPUT);in the setup without any resistors. The default value will float between 0V and 5V: there is no internal or external
voltage reference for the push button.