Mechanical switch

The board is equipped with three mechanical switches. The switches (SW0:2) are shared with LED0, LED2 and LED3. Onboard protection circuitry is added to avoid a short when driving the port high at the same time as pushing the button, which will short it to ground. To be able to use both button and LED, time multiplexing has to be used.

To be able to detect a button press, the firmware has to periodically set the IO pin to input with pull-up and check if it is low. When doing this fast enough, the human eye will not see any change on the LED.