Granted most MCU's are configured such that to 'activate' a device on a logic high (take the simple case of an LED, or a relay or transistor for something higher power) the MCU is sourcing VCC and the other end of the component is pinned to ground completing my circuit.

My question is what would happen instead if the circuit was say, configured another way ? For example, a complete circuit from an external VCC, running through an output GPIO pin, back out of that pin and then to the load and from there to ground of the external VCC. If a logic low output were asserted on the pin would it act as a 'switch' breaking the circuit ? Or would ext VCC simply overload and override the low logic level keeping the short.

Asked, I guess in another way, can GPIO on most MCU be used as a 'switch' in this inverted way ? Presume external VCC is of the same domain as VCC of the MCU.

  • 1
    \$\begingroup\$ The maximum source and sink currents per pin (and per device) are normally documented in the datasheet. \$\endgroup\$ Mar 21, 2016 at 14:42
  • \$\begingroup\$ A microcontroller I/O pin (when set as an output) can generally turn something on in either the high or low state. \$\endgroup\$ Mar 21, 2016 at 14:46
  • 3
    \$\begingroup\$ Schematic, with arrows showing what you think the current flow would be, it's needed \$\endgroup\$
    – Passerby
    Mar 21, 2016 at 14:50
  • \$\begingroup\$ If I'm reading your description correctly then it sounds like you're proposing to use a GPIO pin to 'short-out' Vcc when you want to switch the output off... Very bad idea... Draw it as a circuit and maybe you'll see the problem. \$\endgroup\$
    – brhans
    Mar 21, 2016 at 17:00
  • \$\begingroup\$ You could use two pins and switch them high/low and put a bidirectional LED between them (+ resistor) and switch between two colors with push/pull outputs. \$\endgroup\$
    – Voltage Spike
    Mar 21, 2016 at 17:26

2 Answers 2


"running through an output GPIO pin, back out of that pin"

This is where confusion lies. The current cannot go into the pin, through some component inside the MCU, and then back out of the same pin.

GPIOs on most MCUs can be configured in the following ways:

  • floating input
  • input with pull up
  • input with pull down
  • push-pull output (actively drives line both high and low)
  • open collector output (actively drives line low only, requires external pullup to drive line high)
  • \$\begingroup\$ Dear Chad, Thanks for your response... I am familiar with these std configurations and feel I should at least explain the slightly 'odd' nature of my question--- I was 'just musing' for a bit over the possibility of an open source 'digitally' configured 'breadboard', with banks of resistors and caps, with the routing controlled by a CPLD or MCU. Design would be done by app and then the ICs simply 'placed' on the board accordingly. Yet switching such a network in a 'normal way' would require a ! of external transistors to implement the routing defined by the MCU, so I wondered if poss this way. \$\endgroup\$
    – Nevermnd
    Mar 24, 2016 at 22:27
  • \$\begingroup\$ Also of course I don't mean back up into the chip, but if one did the unusual thing of laying down a double trace to the pin. \$\endgroup\$
    – Nevermnd
    Mar 24, 2016 at 22:50

These two circuits should work:


simulate this circuit – Schematic created using CircuitLab

Note that in the left circuit you must include some kind of current limiter (R1) or you will cause a short circuit when the pin is switched to low.

The right circuit will 'invert' the GPIOs signal: When the output is high no current flows, when it is low it will sink current.


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.