The switch is a digital input module, it acts like the button we introduced before but comes with its own mechanical locking function. It is useful in controlling power connections most of the time.
l The switch is a common switch that has self-lock features. When the switch is pressed for the first time, the switch will remain in on state, which we call self-locking. When the switch is pressed for the second time, the switch button pops up and the switch turns off. The interface of the switch module is a digital interface, it outputs logic low-level and high-level two states.
1. If you push the switch for the first time, the switch will be on, it will output a logic high-level signal.
2. If you press the switch button again, the switch will be off, it will output a logic low-level signal.
Use cases
You could use the switch with output modules, such as a bright LED. You will find that if you press the switch for the first time, the bright LED will turn on all the time until you press the switch again.