I'm following a tutorial that accompanied a starter kit by a company called Freenove. In this tutorial, we're attempting to read the state of a momentary button on a given Arduino pin. I understand the notion of a pull-up or push-down resistor, but it's not clear to me why they are using two resistors in this circuit.
The explanation given is as follows, but, as a beginner, I don't understand what they mean:
In the above circuit diagram, when the button is not pressed, 5V (high level) will be detected by UNO port; and 0V (low level) when the button is pressed. The role of Resistor R2 here is to prevent the port from being set to output high level by accident, which could be connected directly to the cathode and cause a short circuit when the button is pressed.
Can anyone help me interpret this? Thank you.