Unit C - Actuators & Displays

12. Transistors, MOSFETs & Relays

Switch loads safely without overloading an Arduino pin.

Estimated time 4 hours

Learning outcomes

  • Explain why loads need drivers
  • Wire a logic-level N-MOSFET low-side switch
  • Place a flyback diode correctly
  • Use a relay module only with low-voltage loads

Parts and preparation

Uno, logic-level N-MOSFET, 220 ohm gate resistor, 10 k ohm gate pull-down, diode, low-voltage DC fan or lamp and external supply.

Before power: inspect wiring, confirm supply voltage and ensure all connected circuits share GND.

Transistors, MOSFETs & Relays instructional connection diagram
Open the diagram for a larger view. Trace every connection before building.

Driver purpose

Motors, relays and lamps often require more current or voltage than a pin can supply. A transistor uses a small control signal to switch load current from an external supply.

Logic-level MOSFET

An N-channel enhancement MOSFET can act as a low-side switch. Choose a device specified for low RDS(on) at 4.5 V or lowernot only a threshold voltage.

Flyback diode

An inductive load produces a voltage spike when switched off. Place a diode reverse-biased across the coil: cathode to positive, anode to the switched side.

Relay limits

A relay provides isolation between contacts and coil, but contact ratings still matter. This course uses only extra-low-voltage DC; do not wire mains.

Wiring and safe build sequence

Breadboard wiring for lesson 12: Transistors, MOSFETs & Relays
Breadboard layout for this lesson. Match colours and pins before powering the circuit. Click the image for a larger view.
  1. D9 -> 220 ohm -> MOSFET gate
  2. 10 k ohm from gate -> GND
  3. MOSFET source -> common GND
  4. Load between external +V and drain
  5. Diode across inductive load
  6. External supply GND -> Uno GND
Power rule: switch off before moving wires. Arduino I/O pins are control signals; high-current loads require a driver and suitable external supply.
const byte loadPin = 9;

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

void loop() {
  for (int power = 0; power <= 255; power++) {
    analogWrite(loadPin, power);
    delay(10);
  }
  analogWrite(loadPin, 0);
  delay(1000);
}

How the code works

  1. The Arduino drives only the gate; the external supply provides load current.
  2. PWM can control a DC fan or lamp when the driver and load support it.

Test and record evidence

Expected result: The low-voltage load increases in power, switches off, then repeats.

Practical evidence checklist

Common faults and checks
  • Confirm MOSFET pin order from its datasheet.
  • A non-logic-level MOSFET may overheat at 5 V gate drive.
  • Common GND is essential.
Extension challenge: Add a thermistor threshold to control the driven fan, with hysteresis to prevent rapid switching.

Check your understanding

Q1. Why not power a fan from an I/O pin?

Show answer

Its current and inductive behavior exceed the pins safe capability.

Q2. How is a flyback diode oriented?

Show answer

Reverse-biased during normal operation: cathode to positive.