Switch Resistore Mode - GSTCH/SketchMadeEASY GitHub Wiki
In order for a switch to have a defined voltage, it must be set to a fixed level with a resistor. Without this, outside interference can affect the input. This means that the input measures a high even though the switch is open. A defined voltage means that the input is set to 5V or GND using a resistor.
- Pull-up resistor: When the switch is open, the state is HIGH and when the switch is closed, the state is LOW.
- Pull-down resistor: When the switch is closed the state is LOW, when the switch is open it is HIGH.
With Arduino library the mode is set by pinMode. Sketch Made EASY supports three different SwitchResistorModes:
PullDownInternal
This variant does not require any additional resistance. It is the default value or can be set with the value smPullDownInternal or 0.
- Switch open: Value is HIGH (5V)
- Switch closed: Value is LOW (0V)
PullDownExternal
This variant requires an additional high-ohmic resistor. It can be set with the value smPullDownExternal or 1.
- Switch open: Value is HIGH (5V)
- Switch closed: Value is LOW (0V)
PullUpExternal
This variant requires an additional high-ohmic resistor. It can be set with the value smPullUpExternal or 2.
- Switch open: Value is LOW (0V)
- Switch closed: Value is HIGH (5V)