How Electronic Switches Work For Noobs: Relays and Transistors

Picture of How Electronic Switches Work For Noobs: Relays and Transistors
This Instructable is targeted at those just stepping into the world of electronics.

In this guide I will explain how the two main types of electronic switches work, these being relays, and transistors.

Firstly, what is an electronic switch?

An electronic switch is essentially just a switch that uses an electrical current, to turn on, usually turning off when the current is turned off. Some applications of switches can be quite inconvenient for someone to go and press a button to turn on or off, such as for the starter motor in a car, or the "turn off nuclear meltdown" button inside a nuclear reactor, or in an electronics project, a small low power device such as a receiver, must somehow power a large energy guzzling component, like the motor in a garage door opener. And others just want to control their houses with their computer's, which could never possible supply the 240v/120v mains needed to run some appliances.

This guide will include a very noob friendly explanation of the internal workings of relays and transistors. First, we will begin with the simplest one to explain, the relay!
Remove these adsRemove these ads by Signing Up

Step 1: What is a relay

For the beginner, a relay can be a very difficult application to first understand, it was for me, i spent 3-4 days researching for a simple explanation as to how a relay works, and quite recently found myself being asked for an explanation, by a clueless noob who didn't understand.

In simple terms, a relay is a device that uses an electromagnet to mechanically pull two connections together to complete a circuit, in the exact same way your finger mechanically pushes two contacts together in a toggle switch.

A relay is used wherever a small low power device or power supply needs to switch on a much larger one, usually completely isolated from the signals power source, or at a much higher voltage than the signal could provide.

However this is usually not enough to help someone really grasp the idea of how these mysterious boxes work.

Move over to the next step for a better explanation along with an flash animation to show you how it all works.

Step 2: What happens inside the relay?

A typical relay generally has 5 pins on it.

These are referred to as, Input 1, Input 2, COM, N/O, N/C

Here's a better description of what these are and what they do, remembering signal means the power turning on the relay:
  • Input 1: is generally the positive of your relay, where the + of your signal goes, it is at the top of the electromagnet coil that pulls the contact pin
  • Input 2: is where the negative of your signal goes, it is at the bottom or top (end of the coil winding), of the coil, though in most relays it shouldn't matter because an electromagnet just pulls metal towards the center of the magnet. input 2 should always be thought of as negative, as some relays only work one way, but it's up to you
  • COM: is short for common ground, in most cases you connect the negative of the power you are switching to this. If your application uses the same power source , you can connect Input 2 and COM together. COM is the middle terminal, and is connected to the pin that gets pulled towards N/C when power is off
  • N/C: Short for normally closed, this terminal is not connected to COM when there is no signal, but when there is a signal, the pin inside the relay is pulled down until it touches N/C, which would connect it to COM
  • N/O:  short for Normally Open, uses a small spring to make it always touches COM when the magnet is off . N/O is used in most cases to turn on the standby light, as it switches on when there is no power.
  • Contact: is not a terminal, but rather the pin that either connects COM with N/O or N/C. It is often coated in gold or vanadium/platinum to stop it welding onto N/O or N/C.
If you have a relay and a 9v battery laying about, try connecting the + and - pins together, you should hear a small click, this is the pin hitting the contact. when you take power off you'll hear another, quieter click, which is the pin being pulled back to NC

If this still confuses you, i can explain it in pseudo terms which most programmers will get

If input = on (power going through coil)
Else/otherwise (no power)

If you still don't get it, this flash loop should explain far better.

Obviously you can see, when the electromagnet turns on, the magnet pulls the pin towards the N/O contact, and when off, the spring pulls the pin towards the N/C contact.

On the next step there is another animation, this one though is interactive where you press a button to turn on a circuit, which even a 12yo should understand (tested on a 12yo with no prior knowledge, as well as explained what the electromagnet does).
It also shows the internal workings of the relay.

Step 3: Using a Relay

As previously mentioned, relays are used so that small low power components and devices, can switch on larger more power consumptive devices.
The most common examples which most anyone can see for themselves, is in a car.
If you've ever wondered why your car makes that clicking noise when the indicator is on, its because a relay is being switched on and off, by a small timer chip. I don't know exactly what kind, but chances are its a 555 timer.

A 555 timer is used to create pulses (just turn on and off) of any length at any rate, however, it will quickly burn up if more than 200ma is drawn from it.

If we tried to power the indicator lights with a 555 timer, you wouldn't see anything, because it wouldn't be able to supply enough power for the lights to actually do something, even at say 700ma, plus, it would burn up the chip after about 5-10 seconds.

Now, if we were to just use the 555 timer to turn on the relay, which would then connect the indicator lights with the battery, perhaps 50ma would be drawn, a safe load for the chip to handle, while anything up to 5A might be flowing through the relay from the battery, powering the lights.(As a general rule , avoid using more than 100mA from a 555 when powering any kind of coil including a relay)

If you have an expensive new car though, chances are you wont hear that click because either the manufacturer went to the trouble of sound insulating the relay, or a high powered transistor is being used, or MOSFET (similar), probably since your indicators are LED's.

This interactive animation shows you a very simple scenario in which both the N/O and N/C are used, to turn either a red or green light source on depending on whether there is or isn't power going through the relay.
Press the grey switch to turn the relay on, and release to turn off, or hold to keep it on.

Because of the way flash detects mouse clicks, you can trick the switch into saying its still being pressed if you hold the mouse down and move it off the button , if you lock the relay in "ON", just click the switch and it will work properly again.
Obviously this doesn't happen in real life. its just a bug in the code.

Step 4: What is a transistor

Picture of What is a transistor
A transistor is one of the elementary components of most any electronics device.
Although difficult to grasp at first, a transistor is actually very simple and easily relatable to the relay.

A transistor has 3 pins, base, emitter and collector, and comes in two types. PNP and NPN.

Because both work the same, but PNP has reversed polarities, and is a little bit trickier to use than NPN. This Instructable will be about NPN transistors.

the way the transistor works is very much the same as a relay. when power passes through two pins, power is allowed through the two others. in this case though the emitter is shared as the negative.

transistors are used sometimes just like relays, switching on slightly bigger power supplies from low signals, but unlike the relay, the time it takes to switch on is considered simultaneous or instant, which is why it can be used to drive speakers which require high frequencies while relays cannot as there is a delay in the time it takes for the state to switch. Most generic transistors can operate at over 1 million switches per second

transistors also have the benefit of being very small, which means they can be used in places using a relay, would be impossible, or impractical. But, transistors are easily broken by magnetic fields, static electricity and heat, meaning that they have limitations on where they can be used.

Step 5: How a Does a Transistor Work

A transistor works by changing its resistance between the pins collector (power going in), and emitter (power going out), depending on how much current flows through the base to the emitter.

Unfortunately, all transistor's base collector and emitter pins , are in different places varying from transistor to transistor, which is why you'll never find any transistor pin assignment diagrams, that apply to all transistors, and that is why you should never listen to any which aren't exclusively for your transistor.

Transistors unlike relays, can open up by specific amounts, which are directly proportional to the current going through the base.
This proportion is the gain.For example, if a transistor had a gain of 100, then for every 1ma flowing through the base, 100ma could flow through the collector to the emitter, which technically is considered to be an amplification effect. However when you do this, a transistor tends to get rather hot, transistors operate best either when they are fully ON or fully OFF.

All transistors have a maximum input before the input starts to have no effect on the current gain, and eventually, if it gets too high, the current stops all together, which happens only when the voltage on the base is too close or the same to the voltage on the collector.

When we talk about using transistors just as on/off switches, we generally operate at currents that would saturate, or fully switch on, the transistor which is what i will focus on in this guide.

Here is an animation to show you how a transistor works. In the animation, the arrows represent the flow of water, and show that the smaller source is enabling the larger source to flow. This of course is meant to represent the flow of electricity as well, but its easier to just think of it as being water.

From this example its easy to understand why the base must always be less that the collector.
If the flow from the base was the same as or greater than the voltage at the collector, the hypothetical base water flow, would take up the entire pipe, which on its own would block the collector current as there is no room for it.
A situation like this though often results in a combusting transistor.

Step 6: How to use a Transistor

The most common use for a transistor is as a switch,

When current flows from base to emitter, the resistance between collector and emitter drops while there is current flow.

In a simple on/off switch for an LED, where our signal comes from a signal chip, it would work like in the animation.
When the signal goes through the base, it simultaneously allows current to flow through the emitter, which happens because the resistance drops.

Between the base and the signal, there is a low value resistor to ensure the base voltage is less positive than the collector voltage.
if it is (and there is current), the resistance drops and turns on the led.

In this situation, to make it more realistic to a real life problem, we switch on multiple LED's in parallel at a frequency, which is something a 555 would burn up trying to do, if powering the LED's directly off the chip.

Step 7: Notes

Relays come in all different specs. Unfortunately, relays which are built to handle high current and / or voltage, also have larger coils, as they are expected to be able to be used on the same current and voltage they switch, by this i mean they are made so they wont short the current and draw like 10A from the potential 30A current they could switch, which would melt the coil.
this means bigger coils, and as a result, require more power

This means that its unlikely you would find something like a 12v relay capable of switching 30A, which requires only 1mA to switch.

That is with relays alone, but with a relay driver, a signal can be changed to switch a relay that needs 100ma (still not recommended from the 555), to switch on 1uA (micro amp).

Transistors also come in many different shapes and sizes, and s a result, the pin assignment, for pin 1, 2 and 3, will most often be different. When using transistors, always check the datasheet to see which pin is which.

Due to ignorance, many beginners use relays as their electronic switches in their circuits and projects.
Many are put off by the fact that the relay they will need , costs $5-15 , which many of the younger people, would consider quite allot.

In a large majority of these cases, the current being switches might be as little as a few milliamps, but generally only as much as an amp.
People don't realize that a small transistor, could easily handle that 1 amp load , at as much as 50v, whereas the relay is limited to about 28v or so, but can handle up to 10A, which probably isn't even close to what is used.
The relay, would cost around $5-10 at the least at those specs, whereas the 50v 1A transistor, which is not even a power transistor i might add, with no heat sink or anything, would cost about $0.25 ea.

the relay at those specs would take maybe 100-1000mA at 12v to turn on. at 9v, it might need double the current.
The transistor though, would require maybe a couple milliamps, at maybe over 3-5v.

Depending on the voltage needed to switch on the transistor, and what the transistor would switch, you might not even need an external resistor to lower the base voltage.

Step 8: Notes 2

You might be wondering what is the difference between power transistors, normal transistors and mosfets.

Well, power transistors are plain and simply just transistors which can handle more power, and named as such. generally they also have a heatsink attached as they get quite hot in their use. Normal transistors would have a typical range of 0-150v @ 0-2A , anything higher is a power transistor.

A MOSFET though, is actually completely different all together, by the way it works. But it achieves the same outcome.
MOSFET's are also considered to be power transistors, but they handle much higher voltages, which is essentially their main use. High voltage power transistors.
MOSFET's however have either an infinite, or absolute zero resistance depending on their state, meaning that they can safely operate at high voltages with little power dissipation as heat. MOSFET's, like transistors, can also have a variable output, but are dependent on the voltage, not current.

Most all transistors, with higher values, can also switch at higher rates. However MOSFET's even at lowest values, can handle rather high frequencies, simply because of they way they work.

All however, if they can handle the loads, can be interchanged. if a power transistor can handle the load of a MOSFET, chances are it can be used instead, and vice versa.

Step 9: Notes 3: Finding and salvaging relays and transistors

Picture of Notes 3: Finding and salvaging relays and transistors
If like me, you would rather rip open an old TV or toy car for your electronics components rather than pay for them, here is where to look for scrap relays and transistors
Relays: As said before, relays can be found in cars, but these are generally very heavy duty relays, capable of handling over 100A, and consequently require something like 2A to switch.
Smaller more general purpose relays can be found inside microwave boards, Air conditioners (indoor unit) , large, but cheap/simple RC toys , garage door openers, TV's (Large LCD's more-often than CRT) and generally anything that makes a click when it turns on or off.
Surprisingly there are usually 2 or 3 relays inside microwave oven boards , often of different type, such as single throw single pole (SPST), double pole single throw (DPST) and double pole double throw (DPDT)

In each on these, there is a single coil, however there is a different amount of contacts.
When these mention "Pole", it refers to the terminal connected to the pin which would change position, aka, the COM
When these mention "Throw", it refers to the amount of positions that the pin can reside in. single throw switches will not have an N/O, or N/C, depending on the type.

SPST however are the most commonly found on control boards.

Transistors: transistors can be found in most every electronic device in the form of a surface mount, or regular.
You want to avoid surface mount chips as they require a special oven and soldering technique to attach.
Places to avoid are new compact computers, car FM radios and CD players, and most high tech devices.
Places to look for an abundance of removable transistors are RC toy receivers (most often have many moderate duty transistors of both types), old computers and data handling devices like game consoles, electronics kits and projects, simple children's toys, microwaves , TV's , but  big ones (any kind) in particular (also great source of capacitors), many simple output devices , any radio receivers (avoid transmitters) and big portable sound systems (tape players radios, CD player ect).

In most disposable cameras, connected to the transformer you will often find a small PNP transistor, likely marked d2470 or similar.

Despite its looks, this thing can handle massive loads, -8A at -40V (8A at -40V) , and its spec sheet even says it is OK to drive motors, (Good for PWM speed controller) but would require different wiring to a PNP, generally the polarities would be reversed as far as i know.

If you are only really interested in power transistors or MOSFET's, for your high voltage projects though, i advise looking in big speakers and sub woofers, speed controllers (Most common use of MOSFET's), lamp dimmers, volume control ect, DC inverters, anything that spits out more voltage than it takes in (applies to battery DC devices), computer power supplies (caution, capacitors inside can kill), RC toy cars (usually the ones with the big heatsink), microwave oven boards, sometimes TV's, Jacobs ladder kits, ignition coil drivers (Some high tech cars don't use manual distributors anymore) and Pulse width modulation devices (provide variable outputs, like heat, light, audio volume), plus some laser/strobe drivers.

Thankyou for reading my instructable i drew and animated all the content, don't forget to comment, and ask questions if your not sure, or troubled by something.
Feel free to redistribute any content in this guide.
1-40 of 68Next »
DmitryU20 days ago

Thank you!
Finally i catch up with transistor's mechanics! ^_^

15-08-9022 days ago

Great work.Would like to get more knowledge about relay. A brief history of relays and their applications in the electrical.

Manny8923 days ago

Nicely done with excellent examples... I appreciate all the time you put into this...!

AnthonyT112 months ago

Is the description of N/C and N/O backwards in his description? : "N/C: Short for normally closed, this terminal is not connected to COM when there is no signal, but when there is a signal, the pin inside the relay is pulled down until it touches N/C, which would connect it to COM"

I thought N/C should mean that without input(relay off), it's closed in a circuit, i.e. connected to COM. ??,

rhetherington2 months ago

Great explanation! Thank you!

Does that mean that if 2.5mA was applied to the Base only 250mA would be allowed through the Collector creating a total of 252.5mA at the Emitter?

Also why do people say that transistors amplify? - is it just based on the fact they combine both the Collector and the Base?

MalikE22 months ago
chrissp14 months ago

Thanks for this tutorial man, this exactly what i was looking for. But I still need to ask you this. Can i use a regular transistor to replace a burnt out mosfet in a pioneer 760w car amplifier? Or would it cause it to get worse? The transistor i want to use is a ML7808A and the mosfet i want to replace is a P55NE06FP.

If not possible, can you suggest what other kind of transistors I could use to replace it? Just like you i took apart old electronic devices that i had in my garage and wouldn't like to drive an hour to the closest electronic store for such a small component. Thanks in advance.

To answer your question simply: no, you can not replace the MOSFET with the transistor. Now here comes the disclaimer/explanation: the circuit in that amp was designed to drive that MOSFET not a transistor. A transistor uses current at it's base to "control" the flow of current through the collector and emitter pins.

Think about a transistor as a garden hose with your thumb over the end (pretty sure we've all used that trick to squirt someone). The flow varies with the way you move your thumb, just like a transistor. The MOSFET, however, is like the super-soaker. As soon as you pull the trigger (apply voltage), the gun is shooting water. There is no half way off or half way on, you either are blasting someone with as much water as possible or you're not (and usually running cause you're out of water).

The most important thing to anything electronic is the datasheet. The datasheet will tell you EVERYTHING about the device you are working with... even the maximum limits... which... well... you can test if you want. Hence the name, Fusekiller.

Use websites like: datasheetcatalog.com or findchips.com to look up who sells the parts. Even the search engines can lead you to the datasheet. Most of the time they are PDFs.

Putting P55NE06FP into findships.com came up with a distributor offering it for $8.0880. Now, with the datasheet, you can find a cheaper, comparable MOSFET from Newark.com, digikey.com, mouser.com, etc. by using the specs in the datasheet!

Hope this helps,


TharangaW5 months ago

I've guessed how relays work since I've opened a few of my car but never understood the transistor switch. Helped me a great deal. Thank you very much.

live10525 months ago

Thanks very much for this. I understood relays and I thought I understood transistors but could never get them to work on my project board but I didn't know the base current had to be lower than the collector and how you explained that was perfect. Nice one!

kbapana5 months ago

Hey Can I use any transistor to Flash LED If yes then how........

If no then Explain............

Thanks man, that post really helps understand the relay.The one I'm wiring is in a motor control panel and has 8 "pins" though. I'm familiar with NO and NC, COM is a new term to me. I'm not sure how to see what's what with my meter while I'm putting it together inside the panel with no power on. here's a picture that points to it
2015-01-29 13.09.14.jpg
blueshadownet6 months ago

Great Instructable!

trinityx7 months ago

Thank you for taking the time to write this, it's explained very nicely.

Hi. Thanks for the write up, much appreciated and massively useful. I've been told I can use a power MOSFET insted place of a relay on an automotive circuit. The circuit is designed to switch in excess of 14 volts to the headlight bulbs. In the relay circuit, the existing feed to the bulbs is used to trigger the relay and heavier gauge wiring is used to supply the switch side with full power (via a fuse) to the bulbs.

At maximum, ie. for main beam, having both bulb filaments on (H4 bulb), the combined wattage would be 120 watts. A fully charged auto battery with a charging system in good order, supplies in the region of 14.4 volts. Therefore the current requirement for the relay is 8.33 amps.

Most auto relays are easily capable of this and are very resilient devices. For my circuit, would a power transistor suffice or do I need a MOSFET as I've been advised??

Many thanks :-)
AdrianC57 months ago

great introduction for someone who know nothing about the concept. thank you

sina elec7 months ago


brunofgm7 months ago

Thank you very much for this!

Franscois8 months ago

Thank you so much. Will certainly use some of the tips. Cheers.

ktow8 months ago

Fantastic overview. Thanks for all your work. It was well written and the animations were very helpful!

Good effort on how to explain about transistors. Keep it up!!

ajohnnapthali9 months ago

This document is nice..

vimalrkv10 months ago


what is the difference between current controlled switch and voltage controlled switch?

how it differs from each other?

jpoopdog (author)  vimalrkv10 months ago

a current controlled switch is controlled by current, a voltage controlled switch requires a set amount albeit tiny amount of current, but the resistance is determined by the voltage. voltage controlled transistors are FETs like MOSFETs

mufazin11 months ago

the gain proportion mentioned here is the transconductance (Gm) ??

jpoopdog (author)  mufazin11 months ago

i dont actually know. Ive only ever known it as "gain", look up a datasheet and it should hold them term if its not the common aplification gain.

Would I be able to use a FET transistor to turn on/off the signal to an ESC signal wire to control a brushless motor, or would it distort the signal? I want to be able to control whether the signal comes from an Arduino or a RC receiver by switching on or off a FET (one FET for each signal source). I would be controlling the "gate" voltage with the Arduino.

jpoopdog (author)  Hailstorm991 year ago

it wouldnt distort the signal, or at least, not enough to do anything if it did, the PWM signal varies in the milliseconds, so you could probably even do it with a relay.
however, a fet isnt really suited to the role, youde just want a regular transistor, Mosfets are sensitive to static and cost more than the same power rated transistor. since your just controlling a pwm signal, which i beleive is around 5v at a few mA, and most any transistor could turn on and off a thousand times between each cycle of the signal, a transistor is much more suitable.

in short, you dont need a mosfet, a high gain transistor will be fine.

mosfets are only really suited for fast repeated switching of extremely high currents. or super accuracy/precision waveforms.

Oh ok. I was talking to my electronics teacher, and he said that Field Effect Transistors would work better. Then again I don't think he understood my question.
jpoopdog (author)  Hailstorm991 year ago

well yes, it would work better, but its totally unnecesary, like in the same way a Ferrari is better than a station wagon, but that fact is irrelavent when you just need to drive down the road to the supermarket

cmusada1 year ago

Hi i would like to ask some help after reading your tutorial about transistors ive understande the use of transistors a bit more. but still not much but i would like to ask some help. can i use a transistor as a switch to control charging/discharging of a battery. what transistor should i use? thanks in advance :)

jpoopdog (author)  cmusada1 year ago
well this gets a bit tricky. no, you wont want a transistor any more than you would use a push button switch, its possible yes but its wasteful, inneficient and difficult.

for batteries like SLA nimh and nicad, all you need is to output 1.8-2.4v in a bistable circuit that turns off when you reach a certain voltage, that function though is done with transistors. for adjusting the voltage youll want a 5v variable voltage regulator, it uses 3 pins, in, adj/gnd and out, and the output voltage is determined by a resistor connected between two of the 3 pins. for lithium based batteries you need a special kind of variable charger specific to that kind of battery, or just a slow charger which takes days at a safe minimum

i just wanted to make a circuit to measure the capacity of a rechargeable li-ion battery with the use of a arduino. so i cant you use any transistor? how about a relay?

jpoopdog (author)  cmusada1 year ago

Im not sure exactly of the function you want to perform, if you for whatever reason just wanted to do a low voltage cutoff with the transistor then thats fine, for that ide recomend to use a relay though moreover, since its going to be always on, and also, for 3.7v lithium cells, try to find a 5v-12v transistor since they have lesser resistance.

reddynet1 year ago

Great tutorial. Thank you

what transistor(s) would you recommend for doing the setup you have described above? I'm trying to make a strobe light, but the LED I have is a high power Luxeon LED, wich obviously can't run off my 555 timer.

jpoopdog (author)  didgitalpunk1 year ago

well, this depends on the required current, if its an amp or more, just do a general search for transistors which are classified as "power" transistors. In general power transistors are never used for signal deliveries, but instead, switching heavy loads.
one in particular i know and use is called the sd882 NPN (sb772 is the pnp version), it can handle at least an amp but i think can go as high as 2, with a peak of 3 amps. Its a medium-low power transistor and is very cheap.
On the other hand, keep in mind that you can use several transistors in parallel if individually they arent up to the task, though its not recommended since the failure of one could damage the rest.

Thanks for the quick answer!
kgwolf1 year ago

This was a great tutorial; very informative. I am just getting into the world of building circuits, and this write-up was very clear and easy to follow. With regard to switches, is it correct to say that all they do is enable a secondary power source (switch it on)? So if, for example, I wanted to turn a lamp on and off with signals from a microcontroller, it would still need to be plugged into the wall, but with an open circuit, which the switch would then close? Thanks!

jpoopdog (author)  kgwolf1 year ago
yes, but keep in mind, its not so much the fact its a switch, as it is, its a low energy high speed switch which can offer variable currents between saturation and being completely off, plus it CAN be controlled by a microcontroller, wheras a relay or mechanical switch cannot.
A transistor for example, unlike a relay might be used at a super high frequency with PWM, to dim a lamp which which wont turn off between the ON-OFF-ON phase. SOmething like a incandescent bulb would do this.
But in essence yes, a transistor just enables a secondary power source, though, since the signal is encorperated into the current, its primarily thought of an an amplifier
1-40 of 68Next »