Transistor as a switch

This circuits can help begginers to understand a transistor and use it for their ciruits. i will explain the general working of the transistor as a swithch and finally will give you few ideas of how all i used it.

Binary Output with a transistor:
1) Design a circut which allows a PIC processor to drive an LED array. This LED array has the following properties:

Vf @ 80mA = 10.2V ( six red LEDs are placed in series, giving 6 x 1.7V = 10.2V)
Assume that the PIC is only capable of driving 10mA at 5V.
Step 1. Find a transistor which can withstand 80mA.

110 < hFE < 450 ——>meaning you can count on a gain of atelast 300

max IC (Sat) = 200mA ——>meaning this can take 200mA. 80mA is quite small rite.

VCE(Sat) = 0.25V ——>a rough estimate of VCE at saturation

VCEO = 45V ——->meaning this transistor can take +45V when turned off

Step 2: Find a power supply bigger than 10.2V. Arbitrarilly assume a +24 supply.

Step 3: Find Rc to limit the current to 80mA

RC =( 24V-10.2V-0.25V)/ 80mA = 170 ohms

Step 4: Find RB to saturate the transistor. At the lowest gain, to put you just at the point of saturation,
Ib = ICE/hfe = 80mA /150 = 534uA —->150 is typical Hfe for BC107B in datasheet*
RB = 5V-0.7V/534uA = 32kohm

Pick R smaller than this to assure you saturate this stage. Let R = 10k.

switchIn this pic that i got from a random site kindly overlook the ZTX1051A transistor with Hfe>300. i have shown you calculations for BC107.


2) Design a circuit whichuses a single output from the PIC processor, and allows a PIC processor to drive this motor in the clockwise direction at either 0% speed (0V) or 100% speed (+5V). Assume the motor draws 470mA at +5V.

Step 1: Pick a transistor. I'll stick with a BC107 because I like this transistor.

Step 2: Add the motor to the collector. You don't need a current limiting resistor since the motor's armature resistance and back EMF limit the current to 470mA @ 5V.

Step 3: Add RB to saturate the transistor. Worst case, when the gain is minimum (300) and you're just at the point of saturation:
IB = ICE/Hfe = 470mA/150 = 3.14mA

RB = 5V-0.7V/3.14mA = 5.48kohm

Step 4: Just to make sure that you saturate the transistor, make Rb smaller than this. Let RB = 2k.note: The inductance in the motor stores energy in a magnetic field. When the current is turned off (the transistor turns off) the energy in the field has to go somewhere. To save the transistor, place a diode across the motor to allow the collapsing field to drive current through the diode – saving the transistor

motoragain the ZTX1051A is replaced by BC107 and the current at 2k at base resistance is 3.14mA.


3) Design a circuit which can drive the motor forward and in reverse using transistors:This is the transistor version of my ULN2003 H-Bridge
You can use the same circuit as before, only add another NPN and two more PNP transistors. The equations work out
the same for each transistor:
OFF: put the input to 0V. This assures that 0A flow through the diode.
ON: make RB = 2k to saturate this transistor when 470mA flow though it.

IB > 470mA/Hfe = 3.14mA

RB < 5V-0.7V/1.57mA = 5.48kohm

Let RB = 2k.

PNP: BC177(since I picked a transistor with the same gain (Hfe or b)
OFF: put the input to +5V. This assures there is no potential across the base diode and no current flows.
ON: Make RB = 2k to saturate this transistor when 470mA flows through it.
IB > 470mA/Hfe = 3.14mA

RB < 5V-0.7V/3.14mA =5.48k
Let RB = 2k


That will do…..



1) I connected my local FM radio reciever to my parallel port. There are only two switches to operate it. one for selecting channel and the other for reset . just connect it this way below and you can write a code in VB or C to address the ports and to scan or reset.


The two black thigs are the switches.. just pic the two sides which the switch shorts on pressing and make this combination and get your electronic switch working.

2) I have connected my calculator and microcontroller using the same concep.. I will put those pics later as my friend is havin the digi as of now!!

Cheers trying the circuits. Keep giving your coments plas (it will cheer me up!!) –Madan


15 thoughts on “Transistor as a switch

  1. hey madan u ve done a great job,however im an mechanical engineer so could not understand ur circuits ,itll be great if u could juz give a overloook of transistors so that it becomes easy for people like me to understand.

  2. Hi,Then i’l post about it later in december, very busy these days. Ok just for one quick remark. In layman terms let me just explain one switch operation of the transistor here.

    You see three legs? top,lower and left side?Alright now giving a 0v at the left means that the top and lower points are open(Switch closed) . Giving a 5V at the left ments you have connected top and lower leg(Seitch on).

    Alright technical detailed stuff later. 🙂 the above is just a kinda easy interpretation.Cheers

  3. Hi,This is Hari a first year ECE student, i am interested in you above idea “Transistor and ports” but was unable to get the full idea and working . Can you help me out?

  4. hi , madan .

    i have a valve (electromagnetic valve) . i need to connect it to the microcontroller.
    the valve has internal resistance of 17 ohm. and it needs 24 volt to operate and its of 35 watt. when i calculated tha current , it came around 1.41 amp. now my problem is how to choose the switching transistor to controll this valve … please help

  5. wouldn’t it be possible to save pins on the microcontroller by wiring the RB0 directly to the RB2an duse just one pin for both of these. The same goes for RB1 and RB3. These pairs always have the same logical state anyway, so it shouldn’t matter, should it?this way it mould be possible to control a motor both clockwise and the ather way around using only 2 pins. However; as far as i can see I have to use the same voltage for the both the microcontroller and the motor, and also lose 1.4 V over the transistors. That’s not too good, or am i wrong?

  6. yaa we can wire them but we should keep in mind that RB0 and RB2 || RB1 and RB3 don’t get short circuited. but we dont generally use dont directly connect them as we use PWM at RB0 and RB1 for speed control. also sometimes we use conditions like RB0=1 && RB1=1 && RB2=0 && RB3=0 for brake or vice versa. if we connect them directly we can’t use such conditions.

    as for the uC part.. i din’t get ur question

  7. Hey, Madan thanks a lot .
    now i’m clear about choosing the right transistor.
    i’m learning 8051 Microcontroller programming and may be it is usefull when connecting any external device to my Microcontroller Unit
    Thanks Again.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s