Need help basic electro concept

I have trouble understanding why do I need resistor in this picture. Can’t I make a complete circuit without the resistor?

I thought resistors are only for decreasing voltage before it goes into things like LEDs so that it doesn’t get burnt out.

I just started learning arduino and have forgotten all the basic electro concept I learned back in school.

Any help is much appreciated.

Hello,

The resistor in this diagram is a pull-down resistor. It’s important to keep the resistor because you want your signal to be pulled-down to ground when the button isn’t pressed, but you want the “pull” to be weaker than the 5 volts that gets applied to your signal when you do press the button.

If you had a straight connection instead of the resistor, the 5 volt line would be shorted to ground when you pressed the button. If you didn’t have any connection instead of the resistor, your signal line would be floating when the button isn’t pressed.

Hope this helps,