Skip to content

Class Switch2Position

Hans Rothenbuehler edited this page Oct 27, 2024 · 16 revisions

Input Switch2Position

Topic Specification
Description Switch with two position (e.g. On/Off-Switch).
Use one diginal input pin, set in the constructor. Optional is a debounce time (duration to ignore any changes after LOW/HIGH or HIGH/LOW change).
This classes support the SwitchResistoreMode, set in the constructor. Default is internal pullup.
For switch with 3 position (e.g. Forward/Off/Backward) see class Switch3Positon
Constructor Switch2Position (int Pin, ESwitchResistoreMode SwitchResistoreMode, int DebounceTime)
Parameter
Pin: Pin number
SwitchResistoreMode: Optional with default smPullDownInternal (0). Details read Switch-Resistore-Mode. Possible values are:
  • smPullDownInternal (=0)
  • smPullDownExternal (=1)
  • smPullUpExternal (=2)
    Sketch Made Easy hides the different values of the pin and always has the same value
    DebounceTime: Optional with Default=50ms. The interval that must pass before a value changed is accepted. Value in Milliseconds.
  • Range 0 (Open), 1 (Close)
    Const 0: Switch2Position::Off, Switch2Position::Pos0
    1: Switch2Position::On, Switch2Position::Pos1
    Samples Switch2Position* switch = new Switch2Position(4);
    Switch2Position* switch = new Switch2Position(4, smPullDownExternal);
    Switch2Position* switch = new Switch2Position(4, smPullUpExternal, 60);
    Examples 01-Switch and Lamp
    03-Dimming LED with Switch
    07‐Motor variable speed, direction‐ and main‐switch
    09‐Motor toggles between limit switches, main switch
    10‐Main Motor turns between limit switches, second follows
    11-Two motors, one turns after the other

    Wiki

    Getting started

    Classes
    Input

    Actuator

    Condition

    Relation

    RemoteControl

    Common

    Sketches
    Templates

    Examples

    Clone this wiki locally