Fareed Mohmed← All projects

Info page · no simulation · Arduino and electronics

Transistor and Capacitor Basics for Arduino Builders

Learn how a transistor switches a load that an Arduino pin cannot drive, and how a resistor and capacitor make a time delay, with two calculators.

This topic cannot be run safely or meaningfully in the simulator, so this page explains it with diagrams, calculations and sample code instead. Everything here is original.

What you will learn

  • How a transistor works as a switch
  • How to choose the base resistor
  • What the RC time constant means

In short

A transistor lets a small current at the base control a large current from collector to emitter. An Arduino pin can give only 20 mA, but a transistor lets it switch a 500 mA motor or buzzer. A capacitor stores charge. Through a resistor it charges in a curve, and the time is set by R times C.

Try this next

  • Switch a 5 V relay or small motor with a 2N2222 or BC547.
  • Build a delay circuit that keeps an LED on for 10 seconds.
  • Use a 0.1 uF capacitor close to a sensor to remove noise.

Transistor as a switch

An NPN transistor (for example BC547 or 2N2222) has three legs: base, collector and emitter. With the emitter to GND, the load between the supply and the collector, and a resistor from the Arduino pin to the base, the load turns on when the pin is HIGH.

PartTypical use
BC547 / 2N2222 (NPN)100 to 800 mA, hFE 100 to 300
TIP120 (Darlington)Up to 3 A, voltage loss about 1 V, runs warm
IRLZ44N (MOSFET)Up to 30 A with a heat sink, logic level

Capacitor and the RC time constant

When a capacitor charges through a resistor, the voltage rises as a curve. After 1 RC it has reached 63 percent of the supply. After 5 RC it is practically full.

63%1 RC86%2 RC95%3 RC99%5 RCcapacitor voltage (% of supply)

Try the calculators

Transistor switch: base resistor

Capacitor: charging time

Do and do not