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

joaquin

Member
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?
 
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.
 
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.
 
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.
 
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.
 
Back
Top