Slide switches
A slide switch has three terminals and can be used to control two components. It is a type of SPST with two states where external devices can be connected. Its applications include two-way switching, home appliance control, office power control, and others. The functioning of the slide switch can be understood with the help of Figure 7.4:
Figure 7.4 – Connecting two LEDs and a slide switch with the Micro:bit
In Figure 7.4, a slide switch is connected to pin 2 with GND and VCC connections. To observe its working, we have connected two LEDs to pins 0 and 1. The important thing to observe here is that two resistors are also connected to the LEDs. These resistors help control the voltage level of LEDs so that their voltage and current levels don’t vary.
In the following program, we are controlling two LEDs with one switch. Here, we need to assign the LED connections and the switch connection. The rest will be based on the position...