Switches and push buttons
From wikiluntti
Introduction
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
- Internal resistor (20k-50k Ω): Use
INPUT_PULLUP
in setuppinMode( Button_pin, INPUT_PULLUP);
. The default value isHIGH
(1) and by pressing the button the state goes toLOW
. - External pullup or pulldown resistor: Use
pinMode( Button_pin, INPUT);
in the setup. - The bad method: