Robotics · Electronics basics · Grade 8
The transistor — a switch
An Arduino pin gives 20 mA, but a motor needs 400 mA. How does a small current control a large one?
The situation
The motor of a toy robot car takes ≈ 400 mA from a 9 V battery. An Arduino pin gives only 20 mA (the limit is 40 mA) — connect the motor straight to the pin and the microcontroller burns out. How does a small signal control a large current? The answer is the transistor: a three-legged “switch” in a TO-92 package. Calculate the base resistor, bring the transistor into saturation, spin the motor. Then break things on purpose: a base with no resistor, 400 mA through a 100 mA BC547, and a motor switched off without a flyback diode — a 40-volt “spike” on the oscilloscope trace.
Topic
Transistor as a switch: a small current controls a large one. An Arduino pin gives 20 mA, but the motor needs 500 mA: a transistor switch, β and saturation
Key ideas
- NPN transistor
- β and saturation
- Protection diode
Formulas
Active region: the collector current is β times the base current (BC547 ≈ 200, 2N2222 ≈ 100) — the transistor amplifies current.
The base current: ≈ 0.7 V of the base–emitter junction is subtracted from the pin voltage, and the rest falls across the base resistor.
Saturation: if is larger than the current the load can pass, the load sets the current and only 0.1–0.2 V is left across the transistor — it is like a closed switch.
Choosing for a switch: the base current must be times the required (a margin — β differs from one unit to another).
The power dissipated in the transistor: small in saturation (0.2 V · 0.4 A = 80 mW), large in the active region — for a TO-92 the limit is ≈ 0.5 W.
Theory
Why a pin is not enough
An Arduino pin is a weak source: ≈ 5 V and an internal resistance of ≈ 25 Ω, an absolute limit of 40 mA, a normal value of 20 mA. A small motor takes ≈ 400 mA at 9 V, and more than 1 A at start-up. Connect the motor straight to the pin and the current is mA — 4 times the limit: the ATmega328P heats up and burns out, and the motor does not even start. The pin must only give a command; let another source supply the current.
The transistor: E, B, C
An NPN transistor is a three-layer semiconductor crystal with three legs: the emitter (E), the base (B) and the collector (C). If a small current enters the base, a current β times larger flows from the collector to the emitter: (β is the current gain, from 50 to 500). The base–emitter junction is a diode: it needs ≈ 0.7 V, so the base is connected through a resistor. The legs of a TO-92 package with the flat face towards you: BC547 — C B E, 2N2222 (PN2222A) — E B C. If you mix them up the transistor will not work — always check the datasheet.
Three regions: cut-off, active, saturation
No base current ( V) — the transistor is in cut-off: the collector current is zero, the switch is open. There is a base current, but is less than the current the load asks for — the active region: , the surplus voltage stays across the transistor and it heats up (). larger than the load current — saturation: the load sets the current, falls to 0.1–0.2 V, the transistor is like a closed switch and hardly warms up. As a switch the transistor works only in the two extreme states: cut-off or saturation.
The calculation: the base resistor
Motor 400 mA, 2N2222 (β ≈ 100): the required base current is mA. β differs between units and with temperature, so a margin of 2–3 times is taken: mA. Pin 5 V, 0.7 V at the base: Ω → the standard 470 Ω (≈ 9 mA) or 330 Ω (≈ 12 mA). The pin current must not exceed 20 mA: Ω. With no resistor () the base current is limited only by the pin’s internal resistance — ≈ 100 mA: both the pin and the base–emitter junction burn out.
Limits and the flyback diode
Every transistor has a current limit: BC547 — 100 mA, 2N2222 — 800 mA. Connect a 400 mA motor to a BC547 and it burns out in a second. Power: a TO-92 can dissipate ≈ 0.5 W — if 1 W is dissipated in the active region, it smokes within 10 seconds. A motor is an inductive load: when the current is interrupted the coil “tries” to keep it going: — a 40–45 V spike appears at the collector and the transistor breaks down. The flyback diode is connected across the motor, in reverse: it is shut while the motor runs, and when switched off it gives the current a path — the voltage stops at 9.7 V. When the speed is controlled with PWM () the transistor switches off 490 times a second — without the diode it burns out in an instant.
About the model
The circuit is solved by the nodal method. Transistor: = 0.7 V + 20 Ω, , saturation starts from = 0.2 V; β is constant for each type (in a real transistor it depends on current and temperature, falling to ≈ 40 at 500 mA for a 2N2222). Motor: armature 6 Ω + back-EMF (k = 6 mV·s/rad), 1 mH, a load torque with a propeller — at 9 V ≈ 9 300 rpm, 0.38 A. With PWM the average current is taken as (smoothing by the inductance is ignored). Heating: the part of the current above the limit accumulates over time; the package thermal model is s; the spike energy is — after several switch-offs the transistor “breaks down” (in reality this is random, but this is the order).
Did you know?
- The first transistor was made in December 1947 at Bell Laboratories in the USA by John Bardeen and Walter Brattain (a point-contact device), and in 1948 William Shockley proposed the junction transistor; all three received the Nobel Prize in Physics in 1956.
- A single modern processor chip holds tens of billions of transistors: the Apple M2 Ultra (2023) has 134 billion — each a switch like the one in this experiment, only a few nanometres in size.
Inside the experiment
A real board in a hand-inked isometric drawing: turn it, place the parts, wire the circuit, write and upload the code — current and voltage are computed at once, and a wrong connection burns a part. Inside are missions, theory, a quiz and a guided tour.
More experiments in this section
- LED and resistor: Ohm’s law — Grade 7
- Resistors: the colour code — Grade 7
- Voltage divider and potentiometer — Grade 7
- Capacitor: charging and the RC time — Grade 7
- Diode and rectifier — Grade 8
- Measuring with a multimeter — Grade 8