I need a way to invert a digital signal i.e. if the input is high, I want the output to be low and if the input is low I want the output to be high.

I think this can be accomplished with a single PNP transistor, but wanted to verify that here. The voltages that I'm dealing with are less than 5V.

  • \$\begingroup\$ Detailed treatment of a BJT inverter: EE 307 Section 2 MoHAT Project - "The purpose of this page is to guide those interested in the fundamental operations of a BJT inverter." \$\endgroup\$ Mar 30, 2018 at 11:47

4 Answers 4


Or, since you're talking about digital signals anyway you use an inverter.

enter image description here

A is the input (for gates with more inputs that will be A, B, C, etc.), Y is the output. If it doesn't complicate your schematic too much place the symbol with the input to the left.

Nexperia has single-gate inverters. Just four connections: power supply, ground, input and output.

It can be done with a transistor and two resistors, though. It's a simple schematic, but you still have to make a few simple calculations. You'll have exactly the same connections as with the inverter.
BTW, a PNP is an option, but more often an NPN will be used.

edit (re your comment)

enter image description here

If the input signal is high there will flow current through R2 and the transistor's base-emitter junction (base, not gate). This current will be amplified, and the collector current through R1 will cause a voltage drop so that the output will be low. Input high, output low.
If the input signal is low there won't be any base current, and no collector current. No current through R1 means no voltage drop, so that the output will be at +V. Input low, output high.

This already leads a bit further, but like I said in comment to sandun the output is highly asymmetrical. If the output is connected to a capacitor a high output level would mean that the capacitor is charged through R1, which will result in an exponential slope with a time constant R1C. When the output goes low the capacitor will be discharged through a much lower resistance and the slope will be much steeper. You won't get this difference with CMOS gates, which have symmetrical source/sink capabilities.

The transistor version's input will also draw (a small) current when high. The CMOS version will only have a small leakage current both when high and low.

Overall the integrated logic gate is the winner.

  • \$\begingroup\$ I certainly could be confused here, but an NPN turns on when power is supplied to the gate and a PNP turns off when power is supplied. It makes sense to use a NPN for signal amplification, but it wouldn't cause the signal to invert. Thoughts? \$\endgroup\$
    – Matt Ruwe
    Apr 18, 2012 at 17:47
  • 3
    \$\begingroup\$ Gates are for MOSFETs, not BJTs. NFETs turn on and PFETs turn off. But you must make sure the source is connected properly. An NPN and a PNP are BJTs and require some more math to make sure they work correctly \$\endgroup\$
    – ajs410
    Apr 18, 2012 at 17:49
  • \$\begingroup\$ when it comes to the NXP you have very small room of freedom. There are constrains like timing, fan-in, fan out, input noise margins , glitches etc etc. In that case it's more than easy to use a transistor. Just because your not locked by those constrains. \$\endgroup\$ Apr 18, 2012 at 17:50
  • \$\begingroup\$ @Matt - edited my answer. \$\endgroup\$
    – stevenvh
    Apr 18, 2012 at 17:54
  • 2
    \$\begingroup\$ @sandundhammika, If you build your own, you still have limits on fan-out and noise margin (fan-in doesn't apply here). But you have to calculate for yourself what those limits are. If you use the off-the-shelf gate you can just read the datasheet to find out. Furthermore, power consumption (another typical system constraint) is likely to be much better for the off-the-shelf gate. \$\endgroup\$
    – The Photon
    Apr 18, 2012 at 17:55

Yes, this can be accomplished with a single transistor and resistor, but there are chips specifically designed to invert digital signals. Oddly enough, they are called inverters. Check out the 74HC04, for example. That gives you six separate inverters in a single 14 pin package. There are also single inverters (and other small logic gates) available in small SOT-23 packages, which is the same package individual transistors come in.

There is little reason to try to make your own inverter, but yes, it is possible.

Added in response to comment:

As I said, a single bipolar transistor can be used as the basis for a simple inverter. At minimum, you need the transistor and a base resistor. For completeness I'll also add a output load resistor, which you should assume is needed unless you know whatever will be connected to the output will provide the necessary load. There is nothing magic about a PNP transistor in particular. A NPN can be used just as well. Here is how each would be used:

Note that each has 4 connections: power, ground, input, and output. The difference between the two is which direction it loads the input and which direction the output is actively driven versus passively pulled by the load. If you don't care about these issues, then the two circuits are functionally equivalent.

However, this is easier:

It's also faster, takes less steady state power, has higher imput impedance, and is smaller. It has the same four connections the inverters above do. Single gates like this are available in SOT-23 packages, which is the same package single transistors come in. This only requires one external part, the bypass cap. It doesn't need a load resistor since its output actively drives both ways.

Really, for general inverting of digital signals, making your own inverter is silly for normal applications.

Off topic aside about schematic drawing:

The script is really just three lines. Here is the whole file:

@echo off
rem   Creates a nicely filtered schematic GIF file from the raw Eagle output
rem   /temp/a.tif.  The resulting GIF file will be /temp/b.gif, and will be
rem   gray scale.
image_filter /temp/a.tif /temp/b.img -shrink 5
image_copy /temp/b.img /temp/b.gif -form -gray
image_disp /temp/b.gif -zoom 1 -dev medium

It's a very specific one-off script, but works well enough for the purpose. In Eagle I export the schematic to image file \temp\a.tif, run the script which makes \temp\b.gif. The Eagle setting for image export are 600 DPI and monochrome. Really, that's all there is to it. It probably sound more complicated than it is.

  • 1
    \$\begingroup\$ @MattRuwe it would "suffice" but Olin's point is that a dedicated chip would do better (the rise and fall time would be more symmetrical). A PNP can "pull up" to Vdd, but you need something to pull it back down when the PNP lets the output float. That "something" will create asymmetry in the rise/fall time, based on its impedance. \$\endgroup\$
    – ajs410
    Apr 18, 2012 at 17:47
  • \$\begingroup\$ Gotcha, makes sense \$\endgroup\$
    – Matt Ruwe
    Apr 18, 2012 at 17:48
  • 1
    \$\begingroup\$ How come your schematic looks prettier than mine? :-) \$\endgroup\$
    – stevenvh
    Apr 18, 2012 at 18:13
  • 4
    \$\begingroup\$ @stevenvh: Must be because I'm just better. Seriously though, I use Eagle and take some care. After drawing in Eagle, I export the schematic at 600 DPI to a image file, then run a script that filters and shrinks it 5x and writes the result to a gray scale GIF file. That makes the result a reasonable size without pixel artifacts. It does make lines a little fuzzy though, which is the tradeoff for not having aliasing and visible pixellation. \$\endgroup\$ Apr 18, 2012 at 18:24
  • 1
    \$\begingroup\$ @abdullah: See addition to answer. \$\endgroup\$ Apr 18, 2012 at 20:57

Here are some resistor values that work for CMOS signals:

I found this thread because I wanted to wire an older "LCD Digital Backpack" to an Arduino. The Arduino puts out positive serial signals, and the digital backpack wants inverted signals. Newer version of the LCD controller have an inverted/non-inverted jumper, but mine does not. Similarly, it's possible to generate inverted serial signals through software, but it involves running a non-standard library. I wanted to use the standard Serial.write commands.

I initially wired up one of the 4 NORs in a 4001 CMOS quad NOR gate as an inverter, but that takes up a lot of room on my breadboard, and since you're supposed to tie all unused inputs to ground, involves a lot of wiring. (I think I needed to connect all but 3 of the 14 pins on the package; everything but the outputs on the 3 unused NORs.)

I wanted a simpler-to-wire solution. I used the circuit provided by @stevenvh.

Linked here:

enter image description here

I'm dealing with 5V CMOS logic at 9600 baud, so the input impedance is very high/current is very low. Since I'm only switching at 9600 baud, I don't think the asymmetric behavior of the transistor based inverter hurts me much.

I found that a 100K resistor on the input (R2 in stevenvh's diagram) worked, and used a 3.3k resistor as the pull-up resistor at R1. Based on my calculations (I=V/R, 5/3300) this setup will draw <= 1.5 mA in the ON state (Somewhat less due to the internal resistance of the transistor.) I might hook up a pot and see how large a resistor I can get away with an still have the LCD receive a signal.


Here is how you do it the CMOS way:


simulate this circuit – Schematic created using CircuitLab

The power rail voltage can go as high as you like as long as it is lower than the gate breakdown voltage.


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