Insight 2.3.1. Why use a pull-up resistor?
A floating input pin picks up electrical noise and reads unpredictably. Connecting a pull-up resistor, from the pin to the 3.3 V supply, makes the idle state HIGH. When the button closes, it connects the pin to GND, pulling it LOW. This is called active-low logic: pressed = 0, released = 1. The STM32C031C6’s built-in pull-up resistors are typically 40 kΩ, so no external resistor is needed. Figure 2.2.10 shows the breadboard wiring using the internal pull-up. Figure 2.2.11 shows the alternative: an external pull-up resistor on the breadboard.
