EAZYLife STEM LAB · MODULE 08

Transistors and Electronic Switching

Build a transistor-controlled LED, then use a MOSFET to control a small DC motor. Learn how a small control signal switches a larger load current.

Free open lesson Two practical builds Low-voltage only
CONTROL · SWITCH · MEASURE
01 · WHY TRANSISTORS?

A small signal can control a larger current

A microcontroller output pin can provide a control signal, but it is not a power supply for motors, lamps or relay coils. A transistor can act as an electronic switch between the load and its power source. The controller tells the transistor when to conduct; the separate load supply provides the load current.

Control signal → transistor switch → load current

Two common families: a BJT is controlled by base current; a MOSFET is controlled by gate-to-source voltage. Both have limits and require correct drive and wiring.

02 · BIPOLAR JUNCTION TRANSISTOR

Understand the NPN transistor

An NPN BJT has three terminals: base (B), collector (C) and emitter (E). A small base current allows a larger collector-to-emitter current. In switching use, the transistor is driven towards cutoff (off) or saturation (on). The base resistor limits current from the control output.

NPN symbol and current path

BCENPNEmitter arrow points out

The arrow on the emitter points outwards for an NPN symbol. This is a symbol convention, not a reliable way to identify the physical pin order of an unknown component.

Three operating regions

  • Cutoff: base drive is insufficient; collector current is approximately zero apart from leakage.
  • Active: collector current is controlled by base drive and the device's operating conditions. This region is used for amplification.
  • Saturation: the transistor is driven fully on for switching; collector-emitter voltage falls to a relatively low value.

For a switch, do not assume the datasheet's small-signal current gain is a guaranteed saturation design ratio.

03 · MOSFET BASICS

Gate, drain and source

A MOSFET uses the voltage between gate and source to control the channel between drain and source. A logic-level N-channel MOSFET is designed to achieve a useful low on-resistance at a specified low gate voltage. Check the datasheet's RDS(on) at the actual gate voltage you will apply.

N-channel MOSFET low-side symbol

GDSN-channel

The gate draws very little steady-state DC current, but it has capacitance and needs to be charged and discharged during switching.

What to check in the datasheet

  • RDS(on) at your actual gate voltage, not only threshold voltage.
  • Maximum drain-source voltage and continuous/pulsed current.
  • Gate-source maximum voltage and gate charge.
  • Package thermal resistance, power dissipation and safe operating area.
  • Whether the device is genuinely suitable for logic-level drive.

Threshold is not fully-on voltage. VGS(th) is measured at a very small drain current. It does not mean the MOSFET can carry your motor current efficiently at that gate voltage.

04 · LOW-SIDE SWITCHING

Why the transistor goes between the load and ground

In a low-side circuit, one side of the load connects to the positive supply. The transistor connects the other side to ground when switched on. The controller ground and load-supply negative must be connected together for a non-isolated control circuit, so the gate/base voltage has the correct reference.

Basic low-side arrangement

LOADSwitch+V0 VLoad currentNPN / N-MOSFET

Conceptual current path: positive supply → load → transistor → supply negative. The actual transistor circuit also needs the appropriate base/gate drive and protection components.

05 · PRACTICAL 1 · NPN BJT

Build a transistor-controlled LED

Use an Arduino Uno/Nano digital output to control a small LED through an NPN transistor. The transistor carries the LED current; the Arduino pin supplies only the base drive.

Components

  • Arduino Uno or Nano
  • NPN transistor such as BC547, 2N2222 or BC337, after checking its exact pinout
  • 1 kΩ base resistor
  • 330 Ω LED current-limiting resistor
  • Red LED
  • Breadboard and jumper wires

Wiring schematic

330 Ω1 kΩNPN+5 VLEDArduino D9BCEGND

Follow the labelled terminal connections: D9 → 1 kΩ → base; emitter → GND; collector → LED cathode; LED anode → 330 Ω → +5 V. Confirm the physical transistor pinout from its datasheet before inserting it.

  1. Disconnect USB power while wiring. Identify base, collector and emitter from the exact transistor datasheet. Do not assume all TO-92 packages share the same pin order.
  2. Connect the emitter to Arduino GND. Connect the collector to the LED cathode (short lead / flat-side marking, where applicable).
  3. Connect the LED anode through the 330 Ω resistor to +5 V.
  4. Connect Arduino D9 to the base through the 1 kΩ resistor.
  5. Connect the Arduino and LED supply grounds together. In this simple example both use the Arduino 5 V/GND rails.
  6. Upload the sketch below. The LED should turn on for one second and off for one second.
  7. Measure the voltage across the 330 Ω resistor while the LED is on. Estimate LED current with I = V/R.

Arduino sketch

const byte transistorBase = 9;

void setup() {
  pinMode(transistorBase, OUTPUT);
}

void loop() {
  digitalWrite(transistorBase, HIGH);
  delay(1000);

  digitalWrite(transistorBase, LOW);
  delay(1000);
}

Investigate: What happens when you remove the base resistor? Do not perform that test with the Arduino pin connected. Instead, explain why the resistor is required. Compare the measured LED current with the simple resistor estimate.

Keep this first build to a small LED current. Never connect a motor or relay directly to an Arduino output pin. Stop and disconnect power if the transistor or resistor becomes hot.

06 · PRACTICAL 2 · LOGIC-LEVEL MOSFET

Switch a small DC motor safely

This second build uses an N-channel logic-level MOSFET as a low-side switch. The motor has its own suitable 5 V supply. The Arduino controls the gate but does not supply motor current.

Components

  • Arduino Uno/Nano
  • Logic-level N-channel MOSFET, with RDS(on) specified at 4.5 V gate drive
  • 5 V brushed DC motor, small current type
  • 5 V regulated motor supply with adequate current capacity and current limiting
  • Flyback diode rated for the motor current, e.g. a suitable 1N5819 for a small low-current motor after checking its ratings
  • 100 Ω gate series resistor
  • 10 kΩ gate-to-ground pull-down resistor
  • 100 nF ceramic capacitor across the motor supply rails near the circuit (recommended for noise suppression)

MOSFET motor-driver schematic

100 ΩN-MOSFETG D SMOTORD1K / A10 kΩArduino D9+5 V motor supplyK → +5 VA → drainGateDrainSourceCommon GND

Flyback diode is directly across the motor: cathode (banded end) to +5 V, anode to the MOSFET drain/motor low side. The 10 kΩ resistor pulls the gate low while the controller resets or is disconnected.

  1. With all power disconnected, identify the MOSFET gate, drain and source from its exact datasheet. Confirm it is specified for low on-resistance at 4.5 V gate drive.
  2. Connect the source to the motor supply negative. Connect Arduino GND to that same ground.
  3. Connect the motor between +5 V motor supply and the MOSFET drain.
  4. Connect the flyback diode across the motor: banded cathode to +5 V, anode to the drain/motor negative terminal.
  5. Connect Arduino D9 through 100 Ω to the gate. Connect 10 kΩ from gate to source/ground.
  6. Power the Arduino and motor supply. Start with a low current limit appropriate for the motor. Keep the wheel/shaft clear of fingers and loose wires.
  7. Run the sketch below. Change the PWM value and observe the motor response. Measure motor supply current if you have a suitable meter or bench supply display.

Arduino PWM sketch

const byte motorGate = 9; // PWM-capable pin on Uno/Nano

void setup() {
  pinMode(motorGate, OUTPUT);
}

void loop() {
  analogWrite(motorGate, 70);   // low duty command
  delay(2000);

  analogWrite(motorGate, 150);  // medium duty command
  delay(2000);

  analogWrite(motorGate, 230);  // higher duty command
  delay(2000);

  analogWrite(motorGate, 0);    // off
  delay(2000);
}

On a standard Uno/Nano, analogWrite uses an 8-bit command from 0 to 255. The motor's actual speed is not necessarily proportional to this number; load, friction, supply voltage and motor characteristics matter.

Motor current matters: a motor's stall current can be several times its running current. Check the motor datasheet or measure safely with a current-limited supply before choosing the MOSFET, diode, wiring and supply. Do not stall the motor by hand. Never power it from an Arduino 5 V pin or USB port unless the supply is explicitly rated for the motor's current.

07 · BJT BASE-RESISTOR ESTIMATOR

Estimate base drive for a switching BJT

This simplified estimator uses a chosen forced-beta design ratio. It is a starting estimate, not a substitute for a transistor datasheet, output-pin limits or a standard resistor selection.

Estimated base current5 mA
Calculated base resistor840 Ω

Check that the controller output can safely supply the required base current.

Calculation: IB = IC/forced beta; RB = (VOUT − VBE)/IB. The estimate assumes the output remains near its stated voltage at that current. Real GPIO output voltage falls with load, and transistor saturation voltage is device-dependent.

08 · BIASING AND AMPLIFICATION

A transistor is not only a switch

In a common-emitter BJT amplifier, the transistor is biased in its active region so the input signal can move the collector current up and down around a chosen operating point. If the operating point is too close to cutoff or saturation, part of the signal can be clipped. Emitter resistors can improve thermal stability and reduce sensitivity to transistor gain variation. Amplifier design requires analysis of the DC bias network and the AC signal path; the switching estimator above is not an amplifier design tool.

09 · COMPONENT SELECTION AND TROUBLESHOOTING

Check the whole switching circuit

Before choosing a BJT

  • Collector-emitter voltage and collector current ratings.
  • Power dissipation, package and thermal conditions.
  • Base current needed for reliable saturation.
  • Pinout for the exact manufacturer and package.
  • Safe operating area and switching conditions.

Before choosing a MOSFET

  • RDS(on) at the available gate voltage.
  • Drain voltage, load current and transient margin.
  • Gate charge and maximum gate-source voltage.
  • Thermal resistance and safe operating area.
  • Flyback/clamp requirements for inductive loads.

Common faults

  • Load never turns on: check common ground, transistor pinout, LED polarity, gate/base resistor wiring and supply voltage.
  • Transistor gets hot: check load current, saturation/drive, device ratings and wiring. Disconnect power before changing connections.
  • MOSFET partly turns on: check that it is logic-level and RDS(on) is specified at the actual gate voltage.
  • Controller resets when motor starts: the motor supply may be sagging or noisy; use a suitable separate supply, common reference and appropriate decoupling.
  • Switching spike or controller damage: verify the flyback diode/clamp type, current rating and polarity.
KNOWLEDGE CHECK

Test your understanding

1. What controls an N-channel enhancement MOSFET?

2. Why is a flyback diode placed across a DC motor?

3. Does MOSFET threshold voltage guarantee low on-resistance?

KEEP LEARNING · GO FURTHER

Free to learn. More support when you need it.

Explore these open lessons at your own pace. For personalised explanations, project-specific troubleshooting, guided practical training or masterclasses, EazyLife offers paid support tailored to your learning goals.

Free or sponsored lesson referrals may be available through active programmes; they are not guaranteed.

Enquire about guidance