2
\$\begingroup\$

I made a small circuit that when someone push a button a servo rotates to 90° and go back to his initial position after a certain amount of time.

My issue was with the resistor. I needed it to be in a particular position for my small project to work, which confuses me because in the small inner circuit (ground → resistor → input pin → button → source) I thought it was a good idea to get rid of what seem at first a useless cable, so I removed the cable that connects the button to the source and placed the resistor. I connected the input pin directly to the button, but it did not work as I expected.

To make things clearer, I made a picture of the circuit in a different shape.

Enter image description here

I learned that in a circuit the position of the resistor has no impact (Ohm's law).

Why is it like this?

PS: The picture of my Arduino breadboard.

Enter image description here

\$\endgroup\$
7
  • 5
    \$\begingroup\$ Your first circuit, marked "works", cannot work as drawn, as the input pin is connected directly to battery negative. \$\endgroup\$ Commented May 25, 2021 at 1:10
  • 3
    \$\begingroup\$ your circuits are unclear ... there is no GND indicated (the place where you attach the negative probe of your voltmeter) ... that means that only you know how you are performing voltage measurements \$\endgroup\$
    – jsotola
    Commented May 25, 2021 at 1:16
  • \$\begingroup\$ Yep sorry, I don't know for now how to correctly represent a circuit, it was meant for a "high level" clarification of my intent. Here the position of the resistor compared to an input pin and a switch. \$\endgroup\$
    – cortantief
    Commented May 25, 2021 at 2:00
  • 1
    \$\begingroup\$ Arduino input pins usually have built-in pull up resistors, so the only thing you need is a switch between the input pin and GND. arduino.cc/en/Tutorial/DigitalInputPullup \$\endgroup\$
    – Alnitak
    Commented May 25, 2021 at 9:52
  • 2
    \$\begingroup\$ All of those diagrams have the input pin connected to one end of the battery, which should give the pin a constant voltage, regardless of the switch. But in the photo, it looks like you have the input pin connected between the resistor and the switch, which would be the right place. \$\endgroup\$
    – ilkkachu
    Commented May 25, 2021 at 15:15

1 Answer 1

17
\$\begingroup\$

You're right that the position of the resistor doesn't have an impact in the amount of current that flows. But it does make a difference if the voltage at the input pin is important to you.

In the three circuits which don't work the voltage at the input pin is fixed regardless of whether the switch is closed or not.

You need to put the input pin in between the switch and the resistor. Both of these configurations are used in real designs:

schematic

simulate this circuit – Schematic created using CircuitLab

R1 is called a "pull-up" resistor because it keeps IN_1 high unless SW1 is closed.

R2 is called a "pull-down" resistor because it keep IN_2 low unless SW2 is closed.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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