Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksBuild a CPUToolsOpen the lab →

Relay vs transistor: a mechanical switch and an electronic one

A relay and a transistor can both act as a switch controlled by a signal. A relay is electromechanical: current through a coil makes a magnet that pulls metal contacts together or apart, so the controlled circuit is physically separate from the control signal. A transistor is a semiconductor switch with no moving parts: a small voltage or current at one terminal decides whether current flows between the other two. Both can build logic. Relays did it first, in relay control panels and early relay computers, and the same series-and-parallel contact patterns survive as ladder logic; transistors do it in every modern chip. Relays win at isolation and switching big or AC loads; transistors win at speed, size, lifetime and silence.

What each one is good at

Relays give complete electrical isolation between the coil and the contacts, switch AC or DC loads with the same part, and are simple to understand and test, which is why they are still used to switch mains-powered equipment and in safety circuits. Their contacts take typically milliseconds to move, click audibly and wear out over many operations. Transistors switch far faster, have no contacts to wear and are tiny, so a chip holds billions of them; a logic gate made of transistors switches in nanoseconds or less. For relay logic drawn as rungs, see ladder logic vs logic gates.

Switch logic in digiwleea

digiwleea models transistors exactly as switches, which is why relay logic and transistor logic look alike there: switches in series conduct only when all are on (AND), switches in parallel when any is on (OR). You wire NMOS and PMOS switches into gates and then into an 8-bit CPU, in a 40+ level course with an AI tutor (Wleea). Computers have been built from relays too: Harry Porter's Relay Computer uses 415 identical relays for an 8-bit machine, described on our transistor computers page. The logic as switches lesson starts from the switch.

Side by side

RelayTransistor
How it switchesAn electromagnet moves metal contactsA semiconductor channel or junction conducts
Moving partsYesNone
Switching timeTypically millisecondsNanoseconds or less in logic chips
Isolation between control and loadCompleteNone in a basic circuit
WearContacts wear outNo contact wear
Logic useRelay panels, early computers, ladder logicEvery modern chip

No sign-up is needed to start: open the lab and place your first transistor, or read the free theory course. The account (and the AI tutor) are optional.

More comparisons: Digital logic concepts compared

See for yourself: build a logic gate from transistors in the simulator, then follow the path from sand to an 8-bit CPU.

Open the digiwleea lab →

Frequently asked

What is the difference between a relay and a transistor?

A relay is an electromechanical switch that moves metal contacts with an electromagnet; a transistor is a semiconductor switch with no moving parts. Transistors are much faster and smaller; relays give full electrical isolation and can switch AC loads.

Can a transistor replace a relay?

Often, for low-voltage DC loads, and it switches faster and lasts longer. Where the load is AC mains or the circuits must stay electrically isolated, a relay (or a solid-state relay) is usually used.

Can you build logic gates with relays?

Yes. Contacts in series make AND, contacts in parallel make OR, and a normally closed contact makes NOT. Early computers and industrial control panels were built this way, and PLC ladder logic is drawn the same way.

Why did computers move from relays to transistors?

Transistors switch far faster, use much less power, are much smaller and have no contacts to wear out, so far more of them can work together reliably.