2025 Component Abuse Challenge: An Input Is Now An Output

Part of setting up a microcontroller when writing a piece of firmware usually involves configuring its connections to the outside world. You define a mapping of physical pins to intenral peripherals to decide which is an input, output, analogue, or whatever other are available. In some cases though that choice isn’t available, and when you’ve used all the available output pins you’re done. But wait – can you use an input as an output? With [SCART VADER]’s lateral thinking, you can.

The whole thing takes advantage of the internal pull-up resistor that a microcontroller has among its internal kit of parts. Driving a transistor from an output pin usually requires a base resistor, so would it be possible to use the pullup as a base resistor? If the microcontroller can enable or disable the resistor on an input pin then yes it can, a transistor can be turned off and on with nary an output to be seen. In this case the chip is from ATmega parts bin so we’re not sure if the trick is possible on other manufacturers’ devices.

As part of our 2025 Component Abuse Challenge, this one embodies the finest principles of using a part in a way it was never intended to be used, and we love it. You’ve still got a few days to make an entry yourself at the time of writing this, so bring out your own hacks!

12 thoughts on “2025 Component Abuse Challenge: An Input Is Now An Output

      1. This should not happen: a) pullup is just enabled if pin is configured as input, b) yes, driving high now on output can damage pin!
        Transistor holds the output voltage now at 0.8V… a high current for internal transistor. But often CMOS output pins are “safe” for an external short, limiting the max. current possible by its own resistance (but now burning power inside the chip)

  1. In fact it’s further improved if the pull-up is enabled, OUT set to 0, and DDR used to toggle (assuming it’s a software bit-bang application). The base turns off much faster (orders of magnitude!) when current is withdrawn from it — BJTs are in fact voltage-mode devices, they just draw a convenient (sometimes..) base current to tell you when it’s on. ;-)

  2. Sorry, what a nonsense. A pull-down would keep it a “real” input. An output driving low could be considered also as an input. The only way to use this “trick” (whis it is not) is just the fact, that pull-ups can only be enabled, when configured as input.
    The pull-up can be very weak (e.g. 100K), so the transistor should be one with very low base current.
    With MCU VDD 1V2 it might not work anymore.
    BTW: a need to enable pull-up or not, and the actual input becomes floating when not enabled. This can cause an EMC issue: if input pin gets now a high voltage, e.g. due to electrostatic charge or leakage out of base from transistor – the MCU pin could be damaged.
    Internal pull-ups is for avoiding inputs pins floating, not for driving external loads or acting as pull-up for open-drain logic.

    1. No competent IC designer fails to protect a digital input with diodes.

      “very low base current”. The current required to switch a small signal BJT is not fixed; it’s related to the collector current required to pull the collector near to ground. Using your 100k example and assuming a 5 V supply, about 43 uA would flow into the BJT base. For a BJT with a current gain of 100, the collector current could be as high 4.3 mA and still saturate. That allows Rc to be as low as 1.2 kohm, although good design practice would choose a higher value.

      It’s not nice to be so picky to an amateur builder. This circuit is a hack presented on hackaday; using components outside the manufacturer’s intent is the very essence of this site.

  3. Another “problem”: if no pullup enabled = input floating or even pullup enabled and transistor pulls now input to 0.8V… – putting the input pin voltage into “forbidden” voltage range… the internal input pin logic can now start to “oscillate”, trying to see a low or high, always toggling internal logic very fast. It can create a high current consumption, even burning so much current in internal input logic, that MCU (at least this pin) will get fried.
    Technically, this input pin is floating or gets an input voltage level remaining in the transition zone (not low neither high, opening two transistors inside and creating a short current in internal logic). Both conditions (input floating and/or hanging somewhere in between) are not “allowed conditions”.
    Just touching the input pin with your finger could damage the pin (or the ESD protection kicks in).
    Or: the input pin will be “latched up”. So, it might work just once (and you have to power cycle the MCU).

    1. BTW: why do you need this transistor?
      If your solenoid control logic has a CMOS input – as to see in drawing, and as CMOS input not drawing “any” current…
      Just toggle between pullup and pulldown. It will do the same job, but without any issues for MCU pin.
      Just: a voltage translation to 6V does not seem to be CMOS.
      You could also use an external pullup (but way larger as internal pulldown) and just toggle internal pull-down.
      Use an external CMOS level shifter instead of transistor, at best one with Schmitt-trigger input and it works better.
      I do not see really where the “strange” use case should be? This input pin could be also an open-drain output, acting also as an input pin. Just: as pullup you use internal pullup (just weak).
      If open-drain drives low – it becomes an “input” (current flow) and input should read low.

      1. The problem as stated does not specify that the MCU pin has pulldown capability.

        The problem as stated does specify that the pin is “input only”.

        The MCU datasheet will tell whether the BJT Vbe puts the input pin into the “undefined” range. For instance, the datasheet for ATmega328P specifies a low level on input pins to be no higher than 0.3xVcc, which is 0.9 V with a 3 V supply. Assuming a 2N3904 and the values from my corrected example above, Vbe will be below 0.5 V at 25 C and below 0.7 V at -40 C. Good enough for hobbyist work. If capacitively coupled noise turns out to be a problem, 100 pf to ground at the pin should attenuate any noise.

        4000 series CMOS typically allowed supply voltages from 5 V to 15 V.

        I’d be unhappy if this sort of circuit were used on commercial equipment that I paid money for, or that was in a life-critical application. OTOH, it’s just fine for having fun.

Leave a Reply to Greg ACancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.