0
\$\begingroup\$

So I'm pretty new to electronics and just started playing around with the Arduino to learn the basics. In one of the projects there was just a simple button and 3 LEDs that are controlled by the Arduino. Following is the schematic:

Arduino and circuit divider

As there is no explanation in the book as to why there's a 10KΩ resistor, I did some Googling as to why it's there. I found out it's a voltage divider and keeps a 5V \$V_{out}\$ into the Arduino 2 pin.

My question is, is this resistor necessary? I know it follows the following equation:

$$ V_{out} = V_{in} \times \dfrac{R_2}{R_1 + R_2} $$

So if there's no \$R_2\$, I'd be dividing 0 by 0. In which I'm guessing it's a short circuit? But any resistor of like 1Ω would still allow the 5V \$V_{out}\$. Which would mean that any resistor avoids short circuits? What if I don't connect it to ground at all? Can't it flow just directly from 5V to pin 2 through some internal ground?

I'm kind of reluctant to just try it out myself and see what happens out of fear I'm going to fry some components.

\$\endgroup\$
3
\$\begingroup\$

That's a pull-down resistor for the Arduino's input pin. It's there to handle the case when the button is not pushed. Without the resistor, when the button is not pushed, nothing would be connected to the input pin. The pin would have an undefined voltage, which the Arduino might interpret as either a logical HIGH or LOW. Your program that needs to read the button state would not work correctly.

If you tried to replace the pull-down resistor with a straight piece of wire, it would create a short-circuit between +5V and ground whenever the button is pushed. So a resistor is required.

There's nothing magic about the value 10KΩ, but it's a common "standard" resistor value for pull-downs and pull-ups in digital circuits. The resistor must be large enough to prevent dangerous levels of current from flowing between +5V and ground when the button is pushed, but also small enough that the input pin is correctly sensed as a logic LOW when the button is not pushed.

\$\endgroup\$
2
\$\begingroup\$

it's not a divider. The input pin 2 floats at an undefined potential without it. So the resistor pulls the pin to 0V when the switch is not pressed. When the switch is pressed the pin goes to Vcc.

It's called a pull-down resistor (you will also see pullups quite often).

\$\endgroup\$
0
\$\begingroup\$

R2 is 10k. R1 is milliohms (im guessing 10) resistance of the switch. When the switch is closed the voltage would be approximately 5 * (10k / 10000.01) which is basically 5V (it is reduced by maybe 5 microvolts if my estimations are accurate

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.