Switches and push buttons: Difference between revisions
From wikiluntti
| Line 10: | Line 10: | ||
Three methods to wire | Three methods to wire | ||
# Internal resistor: Use <code>INPUT_PULLUP</code> in setup <code>pinMode( Button_pin, INPUT_PULLUP);</code> | # Internal resistor (20k-50k &Ohm;): Use <code>INPUT_PULLUP</code> in setup <code>pinMode( Button_pin, INPUT_PULLUP);</code>. The default value is <code>HIGH</code> (1) and by pressing the button the state goes to <code>LOW</code>. | ||
# | # | ||
# The bad method: | # The bad method: | ||
Revision as of 11:16, 23 July 2023
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 &Ohm;): 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: