Class LoopSwitch - GSTCH/SketchMadeEASY GitHub Wiki

Input LoopSwitch

Topic Specification
Description A shift register control by a a signal (e.g. button): The value iterate through a defined range (MIN...MAX). When pin goes to high the value increases by step width. When pin is low the value is low as well.
Optional is a debounce time (duration to ignore any changes after LOW/HIGH or HIGH/LOW change).
This classes support the Switch-Resistore-Mode, set in the constructor. Default is internal pullup.
Constructor LoopSwitch(int Pin, int MinValue, int MaxValue, int StepWidth, ESwitchResistoreMode SwitchResistoreMode, int DebounceTimeMSec)
Parameter
Pin: Pin number
MinValue: Lowest value, start of increment
MaxValue: Highest value. If the value exceeds this limit, the logic sets it to MinValue.
StepWidth: The value of the class is increased by this number each time the pin is changed to high.
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 MinValue…MaxValue
    Samples LoopSwitch* switch = new LoopSwitch(4, 6, 1, 10, 1);
    LoopSwitch* switch = new LoopSwitch(4, 6, 2, 10, 2, smPullDownExternal);
    LoopSwitch* switch = new LoopSwitch(4, 6, 1, 10, 3, smPullUpExternal, 60);
    Examples Test 14
    ⚠️ **GitHub.com Fallback** ⚠️