Introduction: Controlling High Power With an Arduino
When using an Arduino we often need to control more voltage and/or current than can be handled directly from the Arduino pins. Most Arduino pins can handle 5VDC, and according to the official Arduino store URL, 20ma of continuous current. However, other sources suggest an Arduino I/O pin can handle 40ma as an absolute maximum (without damage to the Arduino). Thirty (30) ma of continuous power should not present a problem for these pins under normal circumstances, although I try to follow the recommendation of 20ma.
Keep in mind that the 5V header on the UNO is not connected through the ATmega328P microprocessor. Thus, it can provide greater current, perhaps up to several 100ma. However, if you use USB power for the UNO, you are limited by the total power provided through the USB port.
To control devices, such as motors, lamps, coffee makers, toasters, etc. that require more voltage and/or current than can be handled directly by the Arduino pins, we need to place a device between the Arduino and those higher requirement devices.
LEDs, 3mm, 5mm, or 10mm, can usually be controlled directly from the Arduino’s pins. However, this is often not true for other devices, as most “real world” devices use more than 5V and more than 20ma.
Three popular “in-between” devices that allow us to control relatively high voltage and/or current with relatively low voltage and current are relays designed for Arduinos, and two transistors: BJT and MOSFETS.
Inexpensive and low power transistors such as the 2n2222 can often be used, but they are, unfortunately, limited in their capabilities. The use of the 2n2222 transistor is discussed in my earlier Instructable tutorial, "DC Motors Tutorial-1/3: Continuous, H-Bridge, Gear".
The tutorial here discusses relays, higher power BJTs and MOSFETS (both small signal and power) with accompanying theory, real circuits, and Arduino sketches. It may prove useful to readers of this tutorial that all the sketches presented use contained-standalone code and do not require any external libraries.
The MOSFET is one of the most popular devices in use today. It appears in our portable computers, phones, cars, etc. It is probable that you will find a MOSFET in almost all devices that use a digital (binary) system for information exchange.
Step 1: Using a Relay - Part 1
Relays are probably the most fun to use of the three types of devices discussed in this tutorial. Although, they are not as pervasive as the MOSFET. They were the first to be developed of the three "in-between" devices discussed in this tutorial.
Their initial development occurred in the mid-1800s, originally to help in telegraphy.
Relays, at least traditional ones, are electromechanical devices.
Early, and of larger-sized than relay’s of today, relays were used in early computers gradually being replaced by vacuum tubes, then transistors, which were in turn replaced by ICs [successively SSI, small scale integration, MSI, medium scale integration, LSI, large scale integration, VLSI, very large scale integration, and today’s VVLSI, very very (very) large scale integration, with billions of transistor equivalents on an IC].
Relay’s also found their way into early telephone exchanges. They can often be seen in black and white movies, usually when the source of a call is traced.
Relays require the least amount of electronics knowledge of the three types of devices mentioned here, and are thus, probably, the easiest to use.
A traditional relay is essentially an electromechanical switch. It usually contains a wire coil which can be activated. The activated coil becomes an electromagnet applying a magnetic force to move a mechanical lever and close a switch, which is otherwise open. Fortunately, relays can be activated with relatively low voltages and current, and can control devices with much higher voltage and current requirements.
Today we also have “solid state relays”. Although they are not relays in the traditional sense, as they have no moving parts.
In this section, I have included some videos, and stills relating to relays, as well as some examples of relays in use with the Arduino UNO.
We can see in one of the attached still photos the output connections for a relay with three connectors: a COM (common) contact, a NC (normally closed) contact, and a NO (normally open) contact. When the relay coil is activated the 'on' connection changes to be between the NC contact and Com. That is, appropriate activation of the relay's coil changes the normally 'off' to an 'on' and the normally 'on' to an 'off'.
A relay can be used to turn 'on' or turn 'off' an electrical or electronic device. Activating a relay reverses the state of what is NO (normally open), and what is NC (normally closed). It is like applying the !, NOT, operator in a sketch.
In one of the video examples, I show the NC (normally closed), and COM (common) contacts exhibit continuity when the relay is not activated, and no continuity when a relay coil has adequate current flowing in it. The NO ( normally open) and COM contacts only show continuity when the relay is active, otherwise these pins are not connected. This activation and de-activation of a relay is used to switch/toggle devices 'on' and 'off'.
In the relay used in this step, there are two LEDs. The red LED illuminates when the power is connected to the relay, and it confirms that power has been applied. The green LED lights only when the relay is activated. The green LED is quite helpful in avoiding problems with high voltage and/or current (see below) and can prevent serious health risks. It can be used to determine when a relay is activated before high voltage or current is connected to the relay.
In the example in this Step, with source code provided, the relay is activated and then left in its always 'on' state.
Some relays are activated by a LOW signal and others by a HIGH signal. That is, some relays work with HIGH Level activation and some with LOW Level activation. You should check your relay to determine which type of relay you have.
The following is the source code for a relay that is activated by a HIGH on its signal line, i.e., a 'HIGH Level' relay.
#define RELAYSWITCHPIN 3
void setup() {
// Set relay signal pin for output
pinMode(RELAYSWITCHPIN, OUTPUT);
}
void loop() {
// Write a HIGH to the relay switch pin
// that is, turn the relay on
digitalWrite(RELAYSWITCHPIN, HIGH);
}
If you copy the code from here, or any of the examples that follow in the Steps below, it is probably a good idea to use Ctrl+T, i.e., Tools -> Auto Format after copying the program into your IDE, as this site compresses blanks and so they are removed from the program above.
It is possible to have the input pins from the Arduino mis-connected to the relay, so be sure and make certain these are correctly attached to your relay. If your relay does not work, this is one of the first things to check. The other item to check is whether your relay is activated by a LOW or HIGH input signal.
Fortunately, as noted above, it is possible to confirm with the green LED, on a relay that has one, when the relay is activated.
Attachments
Step 2: Using a Relay - Part 2
In this part we initially use a relay to control a DC fan and then we use the same physical configuration to control a lamp. We use almost the same code, i.e., sketch, in both examples. In these example, a relay is activated by a low on its input pin.
Only the output devices, and a single variable [to allow a change of the 'on' and 'off' times to five (5) seconds, rather than the ten (10) second intervals in the fan sketch] are changed.
In the first example, in this Step, we use a fan, and in the second example we replace the fan with a lamp, and we change the 'on' and 'off' times to five (5) seconds. It is important to note that the relay is able to handle considerably more voltage and current at its output than either the fan or lamp require.
An examination of the relay's text shows the relay has, at 125 VAC, the capability of handling 10 amps of current. That is, there is more than enough capacity in the relay to handle the lamp. The only change in the lamp sketch is the change in delay times between turning the relay 'on' and 'off'. That time, as noted above, is changed from 10 seconds (10,000 milliseconds) to 5 seconds (5,000 milliseconds).
The source code for the first sketch (with the 10 second delay between relay activations) is quite simple, and is presented below,
#define RELAYSWITCHPIN 3
int delay1 = 10000;
void setup() {
// Set relay input pin for output
pinMode(RELAYSWITCHPIN, OUTPUT);
}
void loop() {
// Write a LOW to the relay switch pin
// that is, turn the relay on
digitalWrite(RELAYSWITCHPIN, LOW); delay(delay1);
// Write a HIGH to the relay switch pin
// that is, turn the relay off
digitalWrite(RELAYSWITCHPIN, HIGH); delay(delay1);
}
The source code for this sketch can also be downloaded, as it appears in my IDE, from the first attached text file. There is no need to include any code libraries.
The second sketch, which uses the five (5) second delay times mentioned, is presented below,
#define RELAYSWITCHPIN 3
int delay1 = 5000;
void setup() {
// Set relay input pin for output
pinMode(RELAYSWITCHPIN, OUTPUT);
}
void loop() {
// Write a LOW to the relay switch pin
// that is, turn the relay on
digitalWrite(RELAYSWITCHPIN, LOW);
delay(delay1);
// Write a HIGH to the relay switch pin
// that is, turn the relay off
digitalWrite(RELAYSWITCHPIN, HIGH);
delay(delay1);
}
The relay acts as a switch. When there is continuity the switch is turned on. When there is no continuity the switch is turned off.
Working with wall voltage can be potentially dangerous. Thus, it is probably advisable, after loading our sketch, to confirm that the green LED is going 'on' and 'off' at five (5) second intervals before connecting the lamp. This insures that the relay is working as planned before wall voltage is connected to our project.
Attachments
Step 3: A Loud Sound Turns a Lamp On.
In this Step we amend the previous circuit and its sketch to include a sound sensor, which is 'read' to turn the lamp 'on' when a loud sound is heard. The loud sound is my voice. Although I say "Lamp On" loudly, it is the first "Lamp" that actually turns the lamp 'on'. The second word On was not really required. I could have said "On" by itself, and this would also have turned the lamp 'on'. A single loud sound is all that was/is required.
Here we 'read' the analog output of a sound sensor, and use it in addition to the relay already connected to the UNO R3. A digital sensor could also be used, but its sensitivity would also need to be calibrated, as does the analog sensor we use output from here.
The analog output (AO) is used in combination with the appropriate sketch to turn the lamp 'on' when a loud sound is heard. The sensor, and its associated sketch, containing an 'if' statement, evaluates the sensor's analog input line, and when the sketch finds a value greater than the value it is looking for, it sends a signal to the relay's input line to turn the lamp 'on'.
The code that does this is included below, and can also be downloaded using the text file attached to this Step.
// Program by R. J. Kreindler, Dec 2017
// to turn lamp on with loud sound
// Identify analog sensor pin
#define ANALOGPIN A1
// Identify relay switch pin
#define RELAYSWITCHPIN 3
// Set the time for lamp 'on'
int delay1 = 5000;
void setup() {
// Set relay input pin for output
pinMode(RELAYSWITCHPIN, OUTPUT);
// Set sound sensor analog pin for input
pinMode(ANALOGPIN, INPUT);
} // End setup
void loop() {
int soundVol = analogRead(ANALOGPIN);
if(soundVol > 40) {
// Write a LOW to the relay switch pin
// that is, turn the relay on
digitalWrite(RELAYSWITCHPIN, LOW);
delay(delay1);
} // End if
else {
// Write a HIGH to the relay switch pin
// that is, turn the relay off
digitalWrite(RELAYSWITCHPIN, HIGH);
} // End else
// Turn relay off at the end of loop
digitalWrite(RELAYSWITCHPIN, HIGH);
} // End loop
Please note that the sound sensor has a sensitivity potentiometer; the blue component in the attached pictures. A closeup of that component is provided in the pictures. Thus, the value I use to determine a 'loud' sound, 40, is likely different from the value you will find and use. The value you will make a comparison against will depend on your sensitivity adjustment.
You may also chose to use the DO, digital output, rather than the AO, analog output.
In this example, I used a sound sensor. Alternatively you may want to use a passive infrared sensor (PIR), or a light sensor, water sensor, etc. You can "read" the output of whatever sensor you select to activate the relay and its attached device. The attached device, obviously, does not have to be a fan or lamp, e.g., it could be an alarm, radio, coffee maker, toaster, motor, television, etc.
Attachments
Step 4: TIP120 Controls LED
The TIP120 is a BJT (bipolar junction transistor). It is a current controlled component. A small amount of current between its base and emitter can control a larger amount of current in its collector to emitter terminals. This current-based view is the one used by electronic engineers, although it might not be one used by applied physicists.
One of the attached files illustrates that a small current flowing between base and emitter can be magnified in the collector to emitter junction.
The TIP120 is a Darlington transistor, also known as a Darlington pair by electronic engineers. It is basically two transistors (hence the use of the term pair), where the output of the first transistor is the input for the second transistor. The extra current amplification, where one amplified output becomes the next transistor's input, (i.e., the emitter of the first transistor is connected to the base of the second) allows the transistor pair to provide more current gain than would be possible if each transistor were to function on its own.
Here we use the Darlington pair primarily as a 'on'/'off' switch rather than an amplifier. This transistor pair was named after its designer Sidney Darlington. It can be produced in a single package, as here, or made up from two individual, standalone, transistors.
A datasheet for a TIP120 can be found at http://www.mouser.com/ds/2/149/TIP120-890130.pdf.
In our example, the current flowing between base and emitter is less than a milliamp and it is used to control a current of about 7.5 milliamps for the LED placed in the collector to emitter circuit. Obviously, 7.5 milliamps does not require a TIP120, as it is well within the current available through any Arduino header.
Fortunately, although the TIP120, or any BJT, is not a requirement here, the principle of using a relatively small base to emitter current to control a higher collector to emitter current is clearly illustrated in this example. The LED is, as its current requirement is not too great, driven directly from an Arduino header.
Two things we should note: (1) the TIP120 switches fast enough in this application to allow us to use PWM (pulse width modulation), and (2) the base to emitter current controls the collector to emitter current, thereby illuminating the LED at various levels.
As noted above, this Darlington transistor is used here as a switch, where it's base is forward biased to switch 'on'. Quite simply, the BJT is switched between no current and current flow, allowing us to use PWM. The relatively small current flow in the base to emitter channel controls a considerably larger current flow in the collector to emitter channel.
The sketch for this example, with an LED driven by the TIP120, is given below,
/*
* Written by R. Jordan Kreindler, 12/2017
* Digital pin 3 goes to 3K resistor than to the BJT's
* base. That is, the base pin of a TIP120.
*
* The LED is in series with 220 ohm resistor,
* both go between the TIP120's collector and
* the five (5) VDC output on the Arduino UNO
*/
int i;
// PMW pin 3
#define BASE 3
int delay1 = 1500
void setup() {
// Set pin for output to control Base pin
pinMode(BASE, OUTPUT);
}
void loop() {
// By incrementing the values of i each time by 40,
// and using analogWrite() to output that value,
// we can use PWM to change thebrightness of the LED
for(i = 0; i <= 255; i = i + 40) {
analogWrite(BASE, i);
delay(delay1);
} // End for
} // End loop
This sketch is also available by downloading the attached text file.
Attachments
Step 5: TIP120 Controls Computer Fan
Here we use essentially the same sketch as before, but as this is a 12DCV fan we also add a "wall wart" 12DCV power supply which provides the needed voltage and current for the 12DCV computer fan and its four yellow LEDs.
Here the speed of the fan as well as the brightness of its LEDs is controlled by sending differing PWM signals to the computer fan. Other than the addition of the power supply and the change of the LED to a fan, no other changes to the circuit were required.
For this transistor, when the base pin is set to turn the transistor on, as in this project, the transistor switch allows more current to flow between the collector and emitter pins of the TIP120 than flows between its base and emitter. A 1N4007 diode was placed across the two pins of the motor, with the line on the diode facing the positive voltage. It is placed in the opposite direction to normal current flow, and so usually has no current passing through it. The 1N4007 is used as a flyback diode to offer a path for the energy produced by the collapsing magnetic field of the DC fan motor when its power is removed.
It is hard to place the diode incorrectly without knowing it, as when placed the wrong way it will shunt the current to the fan, and the fan will not spin. Although the energy produced by a collapsing field, any coil when power is removed may produce a collapsing field. Although this may only occur for a few microseconds, it can produce quite high voltage, in the range of 100s of volts, possibly enough to damage the transistor the coil is connected to.
All DC motors work in an essentially similar manner. So, when using these with an Arduino and a transistor (BJP or MOSFET) it is likely that a user-added flyback diode will be required.
Generally, BJTs are used without heat sinks for output current not exceeding 1 amp. Relays or MOSFETs can be used if you device has higher requirements.
Step 6: The MOSFET
MOSFET stands for Metal Oxide Semiconducor Field Effect Transistor, these are also sometimes known as IGFETs, Insulated Gate Field Effect Transistors, due to a thin insulating layer directly below the Gate (see below).
There are four categories of MOSFETs. There are two main categories and these two categories each contain two subcategories, yielding 2 x 2 = 4 total categories. The main categories are (1) Enhancement and (2) Depletion. Each of these two main categories can be further divided into either n-channel or p-channel type MOSFETs.
Most MOSFETs have three external pins, although internally they have, four pins [Gate(G), Source(S), Drain(D), and Body [B or SS(Substrate)]. The Body, or substrate, and Source pins are usually connected internally, so that we end up with three external pins (Gate, Source, and Drain). MOSFETs with only three external pins are reminiscent of the three pin (Base, Emitter, and Collector) transistors we normally deal with.
In this tutorial we will use the most popular form of the MOSFET, i.e., the n-channel, Enhancement type.
Fortunately, power MOSFETs can deal with higher current than the traditional BJTs we may be familiar with. In some cases MOSFETS can handle over 50 amps. They can also be switched 'on' and 'off' in nanoseconds.
We can think of the Gate (G) as an actual gate, or even a gate keeper, in controlling current flow.
In Enhancement type MOSFETs, there is no initial connection between the Drain and Source as they are separated by oppositely doped material. However, a voltage can be applied to the Gate (see below) to produce a connection.
When the Gate pin takes a positive voltage, the plate it is connected to, which is separated, and in between, both the Drain and Source, attracts electrons to the substrate/body area opposite this plate. This allows a negative area to be formed between the Drain and Source, the Gate being like one plate of a capacitor.
As noted, there is normally positive material opposite the Gate. The Gate lies atop a very thin layer - in the range of 10 to the 3rd Angstrom of Silicon Dioxide, i.e., SiO2 or silica.
The normally positive material of the substrate opposite the Gate is against the bottom of the SiO2. When a positive voltage is applied to the Gate of the MOSFET, it attracts electrons to this normally positive region, that is opposite the Gate, and insulated from it. That is, when the Gate becomes positively charged it attracts electrons in the region on the other side of the thin insulating layer. This opposite region becomes negative. It was originally positive, and so served as a barrier for current flow between the negative Drain and Source.
However with a positive charge to the Gate, the now negative region opposite the Gate, being of the same type as the Drain and the Source, provides a channel through which current can flow. This process of changing a small region opposite the Gate from positive to negative, thereby allowing current to flow between Drain and Source, is known as inversion. The higher the voltage that is applied to the Gate the larger the region opposite the gate becomes.
This property of a MOSFET (at least one that should work with an Arduino board) allows us to use the Arduino board to test if the MOSFET we have is functional or not (see attached video). There is no requirement for a multimeter or oscilloscope for this simple test.
At a certain voltage, identified as Vgs > Vt, i.e., (the Gate to Source Voltage - often the small gs is capitalized and shown as a subscript as is the t in Vt, sometimes we see Vgs(th) - with the subscripts for the first two characters often in capital letters) the Gate to Source voltage is greater than the threshold voltage, we will find some current flowing between the Drain and Source. However, Vgs(th) is just the value at which there is some current flow. It may, or may not, be sufficient for your project. It is, however, useful for knowing when the MOSFET is turned off, as any value below Vgs(th) will turn the MOSFET off.
The Vgs and Vt measures are available on the MOSFET's datasheet. However, keep in mind that this is not a guarantee that the values given on the datasheet will actually be what you find. They are usually values obtained from many measurements, and so are valid only in a statistical sense. However, the likelihood that a particular MOSFET will not be in-line with its datasheet is probably quite low.
A word of caution, look carefully at the datasheet. If it shows a Vgs of 4.5 volts and you are using a 3.3 volt Arduino, this is not the MOSFET for you. The available voltage is too low to provide a full flow of current in the Source to Drain channel.
At some point an increase of the positive voltage to the Gate, will have no effect in increasing the amount of current flowing between the Source and Drain. That is, current flow has a maximum value for any MOSFET.
What we need and what we find from a MOSFET is fast switching and at a relatively low cost.
To produce a conducting avenue between the Source and Drain, we only need to apply a, specified in the datasheet, positive voltage to the Gate to establish an n-type channel between the two and, thus, current flow. This feature of a MOSFET designed for use with a 5 volt Arduino, can be used to test a MOSFET for functionality, although not for specific datasheet values (see attached video).
In the test setup shown here, we use the Arduino to provide the voltage needed but, fortunately perhaps, we do not need to write a sketch to test the MOSFET. This test, although simple, is quite effective in identifying defective MOSFETS.
Many MOSFET have an attached flange, that serves as a heat sink, to allow them to dissipate a large amount of power (see attached photograph).
Step 7: MOSFET Incrementally Brightens LED, and Then Controls Fan
In this first example we can see that the MOSFET switches states rapidly enough to allow us to use PWM, Pulse Width Modulation, to control the brightness of an LED, as is shown. The code for this example is provided below, and can also be downloaded from the attached text file,
/*
Written by R. Jordan Kreindler, 12/2017
PWM digital pin ~3 is in series with 10M ohm resistor
and connected to MOSFET Gate
LED in series with 220 ohm resistor,
and placed between MOSFET Source and Drain
*/
int delay1 = 20;
// PMW pin 3
#define PWM1 3
void setup()
{
// Set PWM pin for output
pinMode(PWM1, OUTPUT);
}
void loop()
{
// By incrementing i we brighten LED in steps
for (int i = 0; i <=255; i++) {
analogWrite(PWM1, i);
// Use delay to make changes in LED brightness
// clearly visible
delay(delay1);
} // End for
} // End loop
A MOSFET can be used to switch devices 'on' and 'off' (see last video where a MOSFET is used to turn a fan 'on' and 'off'). It is this ability to act as a switch that has made it so pervasive in almost all the electronic devices we use, and has made the MOSFET such a common and valuable transistor.
Here we use a 12 DC Volts "wall wart" to provide the needed DC voltage, and current for a DC computer fan (the same fan as we used in Step five above).
The MOSFET here is used as a switch. When the Gate has positive voltage applied electrons are attracted to the layer opposite the Gate, and the switch is turned 'on'. When the Gate is grounded, or otherwise has no positive charge, the switch is closed.
The code for controlling the DC computer fan is given below,
/*
Written by R. Jordan Kreindler, 12/2017
PWM digital pin ~3 in series with 10M ohm resistor
and connected to MOSFET's Gate
Fan placed between MOSFET's Source and Drain Pins
*/
int delay1 = 6000;
// PMW pin 3
#define PWM1 3
void setup()
{
// Set PWM pin for output
pinMode(PWM1, OUTPUT);
}
void loop()
{
// We turn the fan on and off
analogWrite(PWM1, 255);
delay(delay1);
analogWrite(PWM1, 0);
delay(delay1);1
} // End loop
This code can also be downloaded from the attached file.
The drain on the MOSFET produced by the fan, although too high for an Arduino UNO pin, is relatively low. Thus, even a small signal MOSFET such as the 2n7000 would work here. The caveat is that the pins (with the flat side facing towards us) are respectively, 1. S(ource), 2. G(ate), and 3. D(rain), so that connections to the pins would need to be changed if a 2n7000 small signal MOSFET, which can dissipate 0.2 amps - the fan only uses 0.13 amps, were used in place of the MOSFET used in the example.
Step 8: The Not Really Required Experimental Platform
I found it easiest to use an experimental platform for all the examples shown in this tutorial. An experimental platform, while useful, is not strictly required for any of the projects shown. However, if it is not used, a different method of connecting with the transistors, than that shown, in this tutorial is required.
The experimental platform I used came with its acrylic plate covered with paper on both sides of the platform. Included in the package with the experimental platform are five screws, five nuts, and five clear spacers, along with four relatively soft self-adhesive plastic feet.
If you use the same experimental platform I did, peel the paper back on each side of the platform and remove it.
Once the paper is removed the four holes for mounting the Arduino to the platform become easily visible. If you use a different platform, the steps will be similar, although you may not need to remove any paper.
You mount the Arduino on the platform you selected. I only needed to use four of the five screws, nuts, and clear spacers. That is, there was an extra screw, nut, and spacer included in my packages, but one of each was not needed.
The Arduino UNO R3 board has four mounting holes. The clear spacers are placed between the underside of the Arduino UNO R3 and the upper side of the acrylic platform. The spacers are positioned around the screws that pass through the Arduino mounting holes and the holes in the experimental platform. The nuts should be tightened to insure that the Arduino will not move in use.
The underside of the half-sized breadboard is covered with paper pressed onto an adhesive backing. Remove this adhesive paper and press the breadboard, with its now exposed adhesive backing, onto the experimental platform. You should try to place one side of the breadboard parallel to the side of Arduino it is closest to. Next, turn the platform over and mount the four included plastic feet on the four corners of the platform’s underside.
Whatever experimental platform you use, when you finish you should have both the Arduino UNO R3 and a half-size breadboard mounted on it, and four feet on the underside to allow the platform and breadboard to be placed on any flat surface without marring that surface, while providing firm support to the assembly.
The experimental platform I used can be found in a number of places, such as eBay, Amazon, and Aliexpress.
One URL for a similar platform, but apparently one with only four screws, nuts, and spacers is
https://www.aliexpress.com/item/Universal-Experime...
but, obviously, there are several other sites.
Step 9: Afterwards
If you have come to this point congratulations. You should now have a basic understanding of some of the key elements in driving relatively higher voltage and/or current devices with an Arduino and an "in between" device, such as a relay, BJT, or MOSFET. I hope you found this tutorial interesting and of value.
If you have any thoughts or questions, related to relays, BJT, or MOSFETs covered, or not, in this tutorial, or any suggestions for improvement, I would be pleased to hear from you. You can contact me at transiintbox@gmail.com. (Please replace the second 'i' with an 'e' to contact me. Thank you.)