The LED widget supports only virtual pins. Using a momentary push button with Raspberry Pi is a great way to learn how virtual pins work with inputs. In this example, you will see how the LED widget can be turned on and off according to the status of the momentary push button switch. Let's build the circuit using the following items:
- Momentary push button
- Breadboard
- Hookup wires
Build the circuit as shown in the following screenshot. Connect the push button between Raspberry Pi BCM_GPIO pin 23 (WiringPi pin 4) and the GND. If you want, you can attach the push button to the WiringPi pin 1 (BCM_GPIO 18), the only pin that supports PWM output, and modify the code accordingly: