How to use transistor as a switch

A transistor is an electronics component that is also used as a digital switch.  Although, it works similarly to a mere mechanical switch. But a digital high logic signal controls this switch as compared to traditional push buttons. We control traditional switches manually by applying a mechanical force.

Transistor Introduction

We design this digital switch by connecting P-type and N-Type semiconductor materials with each other. When we combine a P-type and N-Type semiconductor materials with each other, a junction is formed between them. This junction is also known as a PN junction or a transistor. This PN junction controls the flow of current across the junction. But this junction breaks by applying a proper biasing voltage across transistor pins.

transistor pinout npn

Transistors have two types such as NPN and PNP. It is a three-terminal device. These terminals are:

  • Base ( When using as a switch, we apply control logic this terminal)
  • Collector
  • Emitter

When we apply a biasing voltage to the base terminal, the PN junction breaks down. After that current can flow between collector and emitter terminals. Otherwise, forward current can not flow through the device.

tansistor saturation and cut off mode

you can check these practical transistors:  2N2222, MPSA42, 2N3906

 Using transistor as a switch

Now we will learn:

  • How to use a transistor as a switch in electronics circuits
  • how to use it as a switch in microcontroller projects.

Where to use?

In any application, we need to interface a transistor with a microcontrollerBut the question that may come to your mind, Why do we need to interface transistor with a microcontroller? Because microcontroller pins can not provide output current more than 3mA and voltage more than 5V. If we want to connect a load that requires a higher operating current demand more than 3mA, it will burn microcontroller. Many output devices will require a transistor switching circuit to operate a high current requirement load such as relays, solenoids, and motors.

How to use it?

This diagram depicts the three operating regions of the transistor such as saturation region, active region and, cut off region.  In the saturation region, it remains fully ON. In cut off region, it remains fully off.  For switching purposes, we only need this device to operate either in fully-on or fully off region. Therefore,  we can ignore the Q – Point and switch it between saturation and cut off areas.

transistor operating regions to use as switch

How do transistors as a switch work?

As we see earlier, we can use two regions only. Now, we will see how a transistor works in these regions.

Cut off region is also known as fully OFF mode. In this mode, it acts as an open switch. To operate the device in cut off mode,  We should connect reverse biasing voltage to both junctions.  Therefore, in this operating condition, the current can not flow between the collector and emitter terminal due to open circuit between these terminals.

tansistor cut off mode

In the saturation region, the transistor remains in full-on mode. The maximum current can flow through the collector to emitter according to the rating capacity of the transistor.  We provide forward biased voltage between base and emitter terminal. It works like a short-circuit between collector and emitter.  The biasing voltage is usually greater than 0.7 volt.

tansistor saturation mode

Example of digital logic switches

This PN junction based device has many applications such as high current load interfacing, relay interfacing, and motors interfacing through microcontrollers. But in all these applications, the basic purpose is switching.

This diagram provides an example to control high power loads such as motors, lamps, and heater.

  • In this circuit, we want to control 12 volts load from a digital logic AND gate. But the output of the AND gate is only 5 volts
  • By using a transistor as a switch, we can drive 12v or even high voltage loads with a 5-volt digital logic signal
  • We can also use these devices for faster switching and pulse width modulation control unlike traditional mechanical switches

transistor as a digital switch example

Motor Controlling Example

In this example, we use dc motor control through a switch. A semiconductor device acts as a switch. In this diagram, we can provide a control signal with any microcontroller such as Arduino, STM32F4 development boards.

A resistor with a base terminal is a current limiting resistor. Because GPIO pins of any microcontroller can provide base driving current less than 20mA. Furthermore, D1 is a freewheeling diode that controls back emf from the motor. It bypasses the back emf effect. We can use any transistor according to power rating of the motor.

In conclusion, if a control signal at the base input is 0 volts. It will provide an ON signal. Because we use a PNP switch in this example circuit. Similarly, it will remain off, its control signal is logic HIGH.

Transistor as a swith motor control example off condition

Transistor as switch with Arduino Example

This diagram shows the interfacing of an Arduino with an NPN transistor and a motor. This circuit is just for a demonstration purpose. Because we provide power to a load through Arduino supply. We can only operate a 5-volt dc motor through this example. If you need to drive a large power motor, you should use a special power transistor and a separate power supply.

Transistor as a swith interfacing with Arduino

Transistor as a switch Proteus simulation Example

This example is an exact replication of the prior circuit. But NPN transistor is used instead. Therefore, controlling signals will operate the opposite.

Transistor interfacing with microcontroller

Video lecture

In the above circuit, a logic probe is used as input from microcontroller and diode D1 is used as a freewheeling diode to allow the current to flow when the device is in an off state. Remember that we have used 3904 just for a demonstration. While selecting transistors, you should take care of the maximum current that can flow through the transistor in ON state. Microcontroller input is just used to operate transistor in on state or off state as shown in the figure below.

Transistor interfacing with microcontroller

Note that it is usual to connect a back emf suppression diode across the output device. This is essential with devices such as relays, solenoids, and motors which create a back emf when power remain to switch off.

Practically we used mostly relays for high current demanding loads. In that case, the transistor used to operate relay and load is connected with a relay.

Transistor as switch Applications

  • Contol high voltage lamps, motors, and heaters
  • Pulse width modulation high-frequency switching
  • Acts as an amplifier

Leave a Comment

twelve − six =