Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: How do microcontrollers not burn when directly wired to a potentiometer?

  1. #1
    Junior Member
    Join Date
    Oct 2016
    Posts
    7

    How do microcontrollers not burn when directly wired to a potentiometer?

    I have done this a million times; connect a potentiometer's center pin to a pin in the microcontroller, and the remaining two pins to ground and vcc.
    The microcontroller still works even though the potentiometer can short the pin to either of the power lines when placed at both extreme positions. I think it has to do with the pin not being able to draw more than a small amount of power. However, it is always discouraged to connect an led directly to a pin; how is this a different thing?

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Posts
    398
    Quote Originally Posted by joaquin View Post
    I have done this a million times; connect a potentiometer's center pin to a pin in the microcontroller, and the remaining two pins to ground and vcc.
    The microcontroller still works even though the potentiometer can short the pin to either of the power lines when placed at both extreme positions. I think it has to do with the pin not being able to draw more than a small amount of power. However, it is always discouraged to connect an led directly to a pin; how is this a different thing?
    With an LED the pin is set to OUTPUT mode, where it drives a load by connecting the pin internally to ground or Vcc through
    FETs in the chip. These FETs have a limited amount of current they can handle before they overheat, depending on the
    microcontroller, usually something like 5 to 40mA or so.

    When reading a potentiometer a pin is in INPUT mode, where these FETs are completely off, and no current flows at all(*),
    so no damage can happen so long as the pin voltage is in the range of GND to VCc. INPUT and OUTPUT modes are
    entirely different in function.

    (*) Well very very small currents may flow, typically measured in picoamps, millions of a microamp, which to all
    intents and purposes is zero current. In input mode a pin can be though of as just sensing voltage.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,709
    Indeed the difference is input versus output mode. If you were to configure the pin with a pot as output, it could lead to problems.

    LEDs are meant to be used with output mode. But they are special case because diodes have a non-linear voltage to current ratio, where you need a resistor or some other way to limit the current.

  4. #4
    Junior Member
    Join Date
    Oct 2016
    Posts
    7
    Thanks for the responses! It makes a lot of sense.
    My confusion came from the fact that in AVR you set a pin to "pull up" mode to send current to a pin; however, I had forgotten that there is also the DDR register. I guess that this works similar in ARM and the so.

  5. #5
    Senior Member
    Join Date
    Jan 2020
    Location
    Toscana
    Posts
    130
    To limit the current on a MCU pin, especially if an input signal can become low impedace like a potentiometer set on the edges, it is good habit to put a resistor of 180Ω with 3.3V systems or 330Ω with 5V systems inline to the MCU input. This limits both current in case of the input being set as output and it limits current enough to significantly reduce the chance of latch-up with discharges, etc.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •