Download PDF YouTube


Arduino’s are excellent microcontrollers but they can only control low-current devices. There are several ways to extend the capability of your Arduino to allow it to drive higher current loads. Today we will look at a couple of them.

Follow along as we learn to use transistors and MOSFETs with our Arduino.


The Arduino is a microcontroller, you probably already know that. The very name “microcontroller” tells us that the primary purpose of this device s to control things.  The “micro” part simply means that it is a very tiny device.

The Arduino, or any microcontroller, is tiny in more than just size. It also has a pretty small current capability, limiting its use to directly controlling only small devices such as single LEDs, OLEDs, and LCD displays.

Transistors and MOSFETs

Of course, that hasn’t stopped us from controlling much larger devices like gear motors and large stepper motors. We accomplished this by using a driver board to take the low-current Arduino control signals and drive the high-current motors.  In these cases, the driver board did all of the heavy lifting for us. 

The driver boards we have been using accomplish their magic using devices like transistors and MOSFETs. These are basic electronic components that are used in a myriad of applications, in fact, the Arduino itself is a collection of transistors on a single chip.

Today we will learn to use these components to extend the current-driving capability of our Arduino designs.

Transistors and MOSFETS

In 1947 American physicists John Bardeen and Walter Brattain, working under physicist William Shockley at Bell Labs in Murray Hill, New Jersey, invented the first point-contact transistor. A year later Shockley invented and patented the first bipolar transistor. 

This work resulted in all three men earning the 1956 Nobel Prize in Physics for their research on semiconductors and their discovery of the transistor effect. And their invention literally changed the world.

Transistors are the basis of virtually every electronic device created today. The powerful desktop computers and compact smartphones we know and love owe their existence to tiny transistors etched onto silicon chips. Advances in medicine, space research and even the Internet itself would not have occurred without the transistor.

Assortment of Transistors

Transistors replaced vacuum tubes and they could act as either amplifiers or electronic switches. We will be making use of the latter capability.

Bipolar Junction Transistors (BJTs)

The “standard” transistor is the Bipolar Junction Transistor, or BJT. These are sometimes just called Bipolar Transistors.

Bipolar Junction Transistors - BJTs

A BJT has three leads:

  • Base
  • Emitter
  • Collector

There are two types of BJTs – NPN and PNP.

BJT with Load

A BJT is current driven, that is to say that it is switched on when current flows between the base and emitter.

BJT Low Current to Base

A sufficient current flowing into the base will switch on the transistor and allow current to flow between the emitter and collector. 

BJT Switched On

When the BJT is switched on it behaves a lot like a diode. In a way you can think of it as a switchable diode.


The Metal Oxide Semiconductor Field Effect Transistor, or MOSFET, is an improvement on the BJT in many ways. It is a high impedance device that uses a low voltage to switch it on.

As with a BJT a MOSFET has three leads.

  • Gate
  • Drain
  • Source


There are two types of MOSFETs, N-Channel and P-Channel.

This diagram illustrates a MOSFET in a circuit with a low voltage source connected to the Gate.

MOSFET Driving Load

When a sufficient voltage is applied to the gate the MOSFET is switched on.

MOSFET Low Voltage on Gate

This allows current to flow between the Drain and the Source. The MOSFET acts like a very low value resistor when it is switched on.

MOSFET Switched On

Since MOSFETs have a very low on resistance they don’t dissipate very much power, so they stay cool even without heatsinks.


So which of the two types of transistors would be best for your design? 

The answer is not always straightforward as both Bipolar Junction Transistors (BJTs) and MOSFETs have their own strengths and weaknesses. 

This chart outlines some of those differences:

Current Controlled. Requires biasing current and limiting resistor. Voltage Controlled. No biasing current or limiting resistor.
Lower impedance. Draws more current. Higher impedance. Draws minimal current.
Higher gain than MOSFETs. Lower gain than BJT’s. 
Larger internal size than MOSFETs. Smaller internal size than BJTs.
Less expensive than MOSFETs. More expensive than BJTs

As you can see in most applications the MOSFET has some distinct advantages over the BJT. But in some cases, such as in the design of amplifiers, or where cost is a factor, bipolar junction transistors can be a better choice.

Our Transistor & MOSFET

Here are the devices we will be using in our ex[periments. Both of them are very common devices that your local electronics store will have in stock. You can substitute other devices with similar specifications.

TIP120 Darlington Transistor

The TIP120 is an NPN Darlington Power Transistor. It can switch loads up to 60-volts with a peak current of 8 amperes and a continuous current of 5 amperes.

A Darlington transistor consists of a pair of transistors in the same package. The emitter of the first transistor is connected with the base of the second transistor and the collectors of both transistors are connected together to form a Darlington pair.

This arrangement improves both the current gain and current rating of the transistor.

Here are the main specifications of the TIP120:

  • NPN Medium-power Darlington Transistor
  • High DC Current Gain (hFE), typically 1000
  • Continuous Collector current (IC) is 5A
  • Collector-Emitter voltage (VCE) is 60V
  • Collector-Base voltage (VCB) is 60V
  • Emitter Base Voltage (VBE) is 5V
  • Base Current(IB) is 120mA
  • Peak load current is 8A
  • Available in To-220 Package


The IRF520 is a Power Mosfet with a 9.2-ampere collector current and 100-volt breakdown voltage. This MOSFET has a low gate threshold voltage of 4 volts and hence is commonly used with microcontrollers like the Arduino for switching high current loads.

Here are the main specifications of the IRF520:

  • N-Channel Power MOSFET
  • Continuous Drain Current (ID): 9.2A
  • Drain to Source Breakdown Voltage: 100V
  • Drain Source Resistance (RDS) is 0.27 Ohms
  • Gate threshold voltage (VGS-th) is 4V (max)
  • Rise time and fall time is 30nS and 20nS
  • It is commonly used with Arduino, due to its low threshold voltage.
  • Available in To-220 package

Popular MOSFET Module

One reason that I chose to use the IRF520 for my MOSFET experiments is that it is available as a low-cost module. The module has a few supporting components, as well as screw terminals for power and the load you are controlling.  It also has a 3-pin connector for connecting to the Arduino or other microcontrollers.

I’ll be using these modules in my MOSFET example, but you could always elect to use discrete IRF520s instead.  I’ll show you both ways in the wiring diagram.

Arduino with Transistors

For the first couple of experiments, we will use the TIP120 power Darlington BJT.  You can substitute a BJT with similar specifications if you don’t have a TIP120.

I’ll be using 6-volt batteries and loads for my experiments, but you can use any DC power source and load up to 40 volts. Don’t try and switch AC voltage using the methods you’re about to see, these are strictly DC circuits.

Basic Arduino Transistor Switch

The first experiment is the basic switch. It’s a simple hookup and sketch and it illustrates how simple it is to control a load with a transistor and an Arduino.

For my high-current load, I’m using a 6-volt incandescent light bulb. You could select another resistive load if you wish.

Here is how I hooked everything up:

Arduino Transistor Switch Hookup

Note that in addition to the Arduino, TIP120, light bulb and battery you’ll need a pushbutton switch and a couple of resistors. The 2.2k resistor limits the current into the base of the transistor, while the 10k resistor is a pull-up resistor for the switch.

Hook everything up and then load the following sketch:

The sketch for our switching experiment is pretty simple. Its purpose is to light the bulb for 5-seconds when the pushbutton is pressed.

We start by defining variables to represent the output pin to the transistor and the input pin from the switch. We also define a variable to hold the pushbutton value.

In the Setup, we set our inputs and outputs, and then write a LOW to the output pin to make sure we enter the loop with the transistor off.

Arduino Transistor Switch on Breadboard

In the Loop, we read the input pin and use its value for the button value. If it is HIGH then the button has not been pressed and the 10k resistor is pulling the input up to 5-volts.

If the button is pressed the input will go to ground and the value will be LOW. We turn on the lamp by setting the output HIGH, which passes current through the 2.2k resistor to the transistor base.

We want our light to stay on for a while so we add a 5-second delay. We then set the output LOW to turn off the lamp and go back and finish the loop.

Arduino Transistor Switch

Load the sketch and observe the results. You can increase or decrease the delay if you wish.

Switching Inductive Loads

The arrangement we just saw with the transistor and the Arduino works well for resistive loads, but for inductive loads, there is another consideration.

What is an inductive load you might ask?

An inductive load refers to any load that passes electricity through a coil. Examples would be motors, relays, and solenoids.

When current is passed through a coil it creates a magnetic field and a small current is generated in the opposite direction. This is sometimes called “reverse EMF” or “backflow voltage”.

A device like a motor or a solenoid can have a large reverse EMF when it is in movement. That reverse voltage can damage transistors, so they need to be protected from it.

The most common method of protecting from reverse EMF damage is to use a diode, wired in the “opposite” polarity. This absorbs the reverse voltage.

In our experiment, we will use an inductive load in the form of a small DC motor.

Arduino Transistor Motor Control Hookup

Note the diode across the motor leads, I used an IN4004 rectifier diode, which is a very common device.

The rest of the wiring is pretty straightforward. Once again I’m using a 6-volt battery to power the experiments high-current side, and we’re using a 2.2k resistor to limit the current into the transistor base.

We have also added a potentiometer so that we can control the motor speed.

Here is the sketch we’ll be using for the motor control:

This is also a simple sketch, it’s purpose is to read the potentiometer position and set the motor speed accordingly.

We start by defining our output to the transistor and the analog input pin used by the potentiometer. We also define a variable t hold the motor speed,

All we do in the Setup is to define our transistor connection as an output.

Arduino Motor Control on Breadboard

In the Loop, we read the potentiometer position and then use the map command to convert it into a range of 0-255.  We then use an analogWrite command to send PWM signals out to our transistor.  This switches the transistor on and off, powering our motor.

Load the sketch and experiment with controlling the motor speed.  Because we are using PWM the motor should have good torque even at the slower speeds.

Arduino Motor Control

If you need to control the speed of a small DC motor and don’t need to reverse it then this is actually a practical circuit.  Just remember that you’ll be losing 0.7 of a volt through the transistor.

Arduino with MOSFETs

MOSFETs have a number of advantages over BJTs. They cost more, but for that extra money, you get much better power dissipation and simplicity in hooking them up to your logic circuits.

We will be making use of the IRF520 N-Channel Power MOSFET for our experiments. I’m going to be using a popular “MOSFET Module” that simplifies hooking up external devices to your microcontroller, but you may also just use discrete MOSFETs instead.

Arduino MOSFET RGB LED Strip Driver

Our experiment will involve using an Arduino to control a 5-meter strip of RGB LED strip lights. We’ll have three potentiometers to control the intensity of all three colors, allowing us to dial-up a rainbow of colors.

You’ll require three MOSFETs or MOSFET Modules to wire this up, as well as a 12-volt power supply with enough current to power the LED strip, which can consume several amperes.

I used the MOSFET Modules in my design, but if you want to use discrete MOSFETs instead you can use this diagram to equate the two.

MOSFET Module with IRF520

Notice that the VCC pin on the module is not connected to anything. Also, the Vin and V+ pins are just tied together.

The diagram does not show an additional 1k resistor and an LED that the module uses to display activity on the MOSFET gate input.

Here is the wiring diagram.

Arduino MOSFET LED Strip Light Control Hookup

In retrospect, you don’t need the connections from the power supply positive to the module V+, they don’t actually go anywhere.  Only the connection to the LED strip positive common is required.

The hookup is pretty straightforward, essentially we are connection the three potentiometers to three analog inputs and the three MOSFET modules to output pins that are capable of PWM.  The LED strip lights are connected to the power supply through the MOSFET outputs.

Here is the sketch we will be using to make all of this work:

Another simple sketch, actually it’s very similar to the one we used to control the motor with a BJT.

We define the pins we’ll be using for the outputs to the MOSFETs, and the analog pins used by the three potentiometers.  We also define three variables to hold the three color values.

In the Setup, we set the pins connected to the MOSFETs as outputs. We also set up the serial monitor, this is optional and is included for troubleshooting purposes only.

In the Loop, we read the three potentiometers, convert their values to a range of 0-255 and then send PWM out to the three MOSFET switches to control our LEDs. It’s pretty straightforward.

Arduino LED Strip Light Demo

Once you get everything hooked up give it a try. If you have trouble getting it to work look at the serial monitor to see what values you’re getting from the potentiometers.

It’s a colorful experiment!


By using BJTs and MOSFETs we can extend the control capability of our Arduino projects.  We are no longer limited to devices under 40ma.

The techniques I showed you here can be used for a variety of DC loads, inductive and non-inductive. But they cannot be used to control AC devices, so don’t even try. There are other methods used to control AC devices, and we will look at them in a future article and video.

Until then you’ll have to limit yourself to controlling the DC equipment in your world.  Have fun!



Code for this Article – All the code used in this article in a handy ZIP file.

PDF Version – A PDF version of this article, great for printing and using on your workbench.

Transistor Theory – An excellent tutorial from Sparkfun.

TIP120 – TIP120 Bipolar power transistor spec sheet.

IRF520 – IRF520 Power MOSFET spec sheet.



Arduino High-Current Interfacing – Transistors & MOSFETs
Arduino High-Current Interfacing - Transistors & MOSFETs
Article Name
Arduino High-Current Interfacing - Transistors & MOSFETs
Learn how to use Bipolar Junction Transistors and MOSFETs to interface high-current DC loads with an Arduino.
Publisher Name
Dronebot Workshop
Publisher Logo

If you have a question...

Comments about this article are encouraged and appreciated. However, due to the large volume of comments that I receive, it may not be possible for me to answer you directly here on the website.

You are much more likely to get answers to technical questions by making a post on the DroneBot Workshop Forum. Your post will be seen not only by myself, but by a large group of tech enthusiasts who can quickly answer your question. You may also add code samples, images and videos to your forum posts.

Having said that, please feel free to leave constructive comments here. Your input is always welcome. Please note that all comments may be held for moderation.

Newest Most Voted
Inline Feedbacks
View all comments
CF Malan
1 year ago


That for an awesome lecture on the Mosfet, is it possible that you can share the source code


JT DeWitt
1 year ago

I concur with CF Malan. That was a great lecture on BJTs and MOSFETs. It was very enlightening and helpful. I do appreciate it a lot. The source code would be helpful. But it can be recreated from your video if necessary (or what’s above in this article). Do you happen to know the part numbers of the boards you used in the demonstration which had the MOSFETs packaged on them? You gave the circuit so it wouldn’t be too hard to recreate it. But the boards do seem convenient. Thanks again.

Dave Kosewick
1 year ago
Reply to  JT DeWitt

Just go to Ebay and search for “IRF520 module”, you’ll get a selection to choose from.

1 year ago

Really appreciate this article on BJTs and MOSFETs.. Can I assume you can parallel the MOSFETs to handle larger current loads?

1 year ago
Reply to  Jay

you can use them in parallel, however there is a capacitance that increases and that will keep all the mosfets from turning on at the same time.You can probably find a explanation on youtube.

Adam W
11 months ago

Thank you for sharing your wealth of knowledge! I’m a software developer who’s just getting into hardware & electronics, and your site has been extremely useful!

I’m working on an arduino project that requires both a 12V DC motor and 12V DC solenoid. I have a few of the same MOSFET modules (IRF520) that you are using in this article. Can I use these MOSFET modules with a 1N4007 rectifier diode for both the motor and solenoid?

Thanks for all your help!

Ralph M Bohm
9 months ago

I am looking at a site on Amazon that shows 10 of these IRF520s at:
Would these be the same thing?

Khurram Akhtar
9 months ago

Thanks for a great tutorial and comprehensive documentation. Can you please cover the other side of the board and make a video in your style about interfacing high voltage signals to arduino, like connecting proximity sensors to arduino. Yes there is information available about voltage dividers, optocoupler boards and logic level shifters but none is as good as you would make and explain.

Subramanian Sastry
9 months ago

You have a very well organized and beautiful workshop.
Impressed by your lectures and specially on controlling the RGB LEDs.
As an extension of the same can we control four computer cooling Fans with PWM i/p to PWM o/p of Arduino UNO also using the LCD shield with buttons to set individual speed for each fan.Seek your advice, thanks.

7 months ago

Hello there!
I have a few questions about the wiring (seen at 18:30 in the video).

  • Why is there need to connect the negative electrode of the battery to the Arduino GND? Why don’t we simply connect it to the Emitter?
  • Why is not the push button in a seperated circuit using Arduino’s GND?

Many thanks for your work!

6 months ago

Hi,   I’m new to this forum, & also to Arduinos & (attempting) to use MOSFETS & Arduinos together to control real world objects.   I wanted to use an arduino to control the current through a load, by leveraging the conductive range of a IRF540 MOSFET between 2.0Volts to saturation at 4.0volts. The idea being that at 2 volts the mosfet ‘appears’ to the load as a high value resistor, till 4.0 volts when the resistance disappears & the MOSFET appears to be closed switch.   To play around with this, I took 5v from the 5v line, ran… Read more »

4 months ago

I can only say, the best I have ever seen, best greetings from austria

3 months ago

that’s is the most useful lecture I’ve ever seen.

3 months ago

hi i can IRF520N module
the red one to control the PWM source on the LED 80V 1A?

Matthew D Eurich
2 months ago

Your presentations are very clear and to the point. Very helpful thank you.

ray ratell
19 days ago


ray ratell
19 days ago

i need to know how to control the speed of a dc 12 volt motor with a rotatary encoder. i have 2 enciders i like them both! i do not know if they will work as i want them to work. i only need ((( 90 degrees of ratation ))) from 0 to 100 percent or 0 to 12 volts using a arduino if i could make 1 of these work it would be a start for what i want to do! here is the encoder number. made by calt. p3015-v1-cw360 360 rotation clock wise i can get this model… Read more »

13 days ago

Great video style BUT IMHO it would have been better to separate mosfet and bjt into two separate vids. They are different devices. its confusing to mix the two together . There is so much you havent said about mosfets N type P type Drivers cross over conditions, reverse diode effect etc

Would love your thoughts, please comment.x