Microcontrollers—such as the ATmega328P chip that powers the venerable Arduino Uno as well as the Nano—allow you to take input from sensors, power LEDs, and send signals to other devices over protocols such as I²C. If, however, you need to control a larger load, like a large array of LEDs or a DC motor, microcontrollers alone don’t have enough power to directly control any of these devices.
For example, per the Arduino Uno’s tech specs, the board is only capable of generating 20 mA per I/O pin, with an absolute maximum of 40 mA each. This, along with further restrictions when certain pins are used together, doesn’t give you a lot more power than what’s needed for basic communication tasks. Fortunately, transistors present an excellent solution to higher power needs. This article will introduce you to the world of transistors, or re-acquaint you a tech that you may have some familiarity with.
Transistors
Versions of the transistor, which form the building blocks of all modern computing devices, were conceived of and patented in 1922 by Julius Edgar Lilienfeld, and separately by Oskar Heil in 1935. However, the device wasn’t fully recognized until 1947, when physicists John Bardeen, Walter Brattain, and William Shockley produced a functional device while working at AT&T’s Bell Labs. They shared the Nobel Prize in 1956 for this revolutionary device. While it was named an IEEE Milestone in 2009, it wouldn’t be an exaggeration to call it the IEEE Milestone, as nearly all of the modern electronic devices that we use today wouldn’t be possible without it.
Transistors come in different forms, but they all take a small signal, and amplify it between a pair of terminals. These terminals are known as the emitter, base, and collector in the case of bipolar junction transistors (BJT), and source, drain, and gate in the case of field-effect transistors (FET). Among those broad categories, BJTs can be further divided between NPN and PNP (for Negative-Positive-Negative and Positive-Negative-Positive) variations, and FETs can be either JFETs (junction field-effect transistors) or MOSFETs (metal-oxide-semiconductor field-effect transistors).
Breaking that down even further, there are numerous part numbers of each type, with different voltage, current, and temperature ratings. This variety is excellent if you know what transistor characteristics you need, but if you want to jump in and try switching a motor or similar load with a one, knowing what to buy can be daunting. Fortunately, with a quick web search, you can find assortments of transistors with a variety of part numbers and construction, allowing you to jump into experimentation without yet being an expert.
A Simple Circuit

If you’d like to try your hand at using these devices, the simplified circuit pictured above and outlined here will give a quick introduction. In it, a common 2N2222 NPN BJT transistor is used to switch the load of a PC fan with the yellow signal wire running from the positive voltage to the middle or base transistor pin. An output from a microcontroller could be substituted for the yellow wire for control. Since the fan is labeled as requiring .2 amps at 12 volts, this is well beyond the recommended 20 mA (.02 A) for an Arduino board, and a transistor is used to amplify the output effect.
In this NPN transistor setup, when positive voltage is applied to the base, it lets electricity flow through the load, attached between the supply voltage and collector pins, to the emitter, attached to the ground pin. Note that in practice, you’d want to use the appropriate resistor between the signal voltage and transistor base, not pictured above.
Other Transistor Uses
While turning a load on and off is interesting, there are many other things you can accomplish using a microcontroller/transistor arrangement.
- PWM Control of RGB lighting: As shown in this write-up, you can power multi-colored LED strips using a power NPN transistor or N-Channel MOSFET. While you can do this with a single LED using a microcontroller directly, by varying PWM signals, transistors cause this action to be multiplied. This controls the current necessary to power a full strip of LEDs, incrementally taking them to full brightness all the way to an off state. Another alternative is programmable RGB LEDs, which are able to interpret digital signals on each module individually. This gives a huge amount of control, and lets you forgo using individual transistors to switch the power outputs. On the other hand, each RGB LED module uses tiny transistors to control brightness of each element, reinforcing the idea that nearly all electronics use them in one form or another.
- Relay Control for Extreme Loads: Relays perform a similar function to transistors, allowing a separate electrical signal to be controlled by an output. As noted here, while they can sometimes be controlled by a microcontroller directly, they can require current to operate that’s at the fringes or out of the range that these chips can handle. Transistors are used to multiply the microcontroller signal controlling the relay, which can then switch an even larger load. While transistors and relays are interchangeable in some situations, relays present some unique pros and cons. They can entirely isolate one circuit from another, meaning if you have a device you know nothing about and simply want to substitute a relay output for a button, you can do this. They can’t switch as fast as transistors, however, making them inappropriate for PWM control in most situations.
- Audio Amplifier: Perhaps the most common usage for the word “transistor” in modern—or perhaps recent past—vernacular is as part of the term “transistor radio.” While they are used in many other applications today, using transistors instead of vacuum tubes to amplify audio signals, allowed radios to become portable and work with much less power than the vacuum tube models that came before. As noted in this article, you can build an audio amplifier with only six components, taking a low-power signal from an MP3 player, and amplifying it for use on desktop speakers.
Of course, this is just an extremely small sampling of what can be done with these amazing devices. While they can be great for enhancing the abilities of microcontroller projects, even if you never dabble in them directly, it’s great to have a basic understanding of this technology that literally provides the brains for our connected world.
Zach Wendt and Jeremy S. Cook are engineers who write about how electronic components can best be applied in projects. Zach, with Arrow Electronics, has a background in consumer product development. Jeremy has worked in manufacturing automation and writes for a variety of technical publications. You can learn more about microcontrollers here.