The silicon transistor was invented in 1954 and has been considered one of the greatest inventions in the history of technology. Its invention practically spawned the field of electronics and contributed to all of our modern computers, iPods, phones, etc. If you've ever asked what a transistor is or does, you probably were told that it is like a switch. However, it is a bit more complicated than that.

This Instructable will detail a basic transistor and what it can be used for. I am making this because I have had a box of assorted transistors for a while and never really knew how to use them in circuits. After reading some tutorials online I combined some ideas together and figured out how to use transistors in basic circuits.

I will demonstrate the use of transistors by controlling PC fans from a computer's LPT (parallel) port. Then I will implement a simple form of PWM (pulse-width modulation) to control the fan's speed. This demonstrates the ability of transistors to use low-voltage, low-current signal lines (such as a parallel port or microcontroller IO line) to control higher voltage, higher current devices like motors (in this case, PC fans).

Step 1: How a Transistor Works

In this instructable I will be focusing on NPN transistors. A transistor has three terminals: Base, Emitter, and Collector. The base terminal is connected to the signal voltage, the collector is connected to the load, and the emitter is connected to negative (ground). Whenever the base voltage is zero, the collector voltage is also zero. Applying a small current to the base causes a proportionately larger current to flow through the collector. By doing this, a tiny amount of current from a signal can be used to drive larger currents to power heavier loads such as relays and motors.

Note that the load and the signaling devices must share a common ground. In the case of a fan (running from an external power supply) and a computer's LPT port, you can connect the ground terminal of the power supply to the ground pin on the LPT port to achieve this. For a microcontroller you can use the same ground for the chip and the load.

For my examples I soldered three NPN transistors to a small PCB and wired all of the emitters together to form a common ground. I did this to make connecting things easier. In the following examples I am only using one of the transistors. The other two are not affecting anything and can be disregarded entirely. The transistors are "MPS A06" labeled. According to the datasheet they can control up to 300mA and have a voltage limit at 80V. On my PCB, the brown wires are common ground, blue is collector (load), and white is base (signal).
What is the code if i use c++ aur visual basic 2008? Can any one help me
how can i use it to produce a square wave current. that will then be amplified by mosfets. the frequency must be variable
 how to set up the experiment for the fan speed testing please?
Look at the diagram in Step 3, it shows how to wire the fan, power supply, transistor, and parallel port.&nbsp; On the software side you need to produce a pulse-width modulation signal (turning on and off really fast)&nbsp;with a specific duty cycle (duty cycle is the ratio of time on to time off, a 10%&nbsp;duty cycle has the switch on for 1/10th of the full cycle time, so 0.1ms if you are using a 1 millisecond cycle time).<br /> <br /> In code, you can use a loop from 1 to 100 that sleeps a constant amount of time each iteration and turns off the pin when the counter hits the desired duty cycle percentage.&nbsp; Put that loop in an infinite loop that first turns the pin on before starting to count.<br /> <br /> C++&nbsp;example:<br /> <br /> while(1)<br /> {<br /> &nbsp; //turn lpt on<br /> &nbsp; for(int i = 0; i &lt; 100; i++)<br /> &nbsp; {<br /> &nbsp;&nbsp;&nbsp;&nbsp; usleep(1);<br /> &nbsp;&nbsp;&nbsp;&nbsp; if(i == duty_cycle)<br /> &nbsp;&nbsp;&nbsp;&nbsp; {<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //turn lpt off<br /> &nbsp;&nbsp;&nbsp;&nbsp; }<br /> &nbsp; }<br /> }<br />
&nbsp;this is a cool experiment, i will be doing this! thanks
Awesome, going to order an Arduino this weekend. This method works for any general signal-level output (microcontroller, parallel port, arduino, etc). I ported my PWM generator to regular AVR code over the weekend and tested it on a board I borrowed, seems to work better on the AVR since it has a steady clock and output. You can also use PWM output to control hobby and robotics servos. Their signal pins can be driven via parallel port or microcontroller as long as you connect the ground from the motor to your parallel port's ground or microcontroller's ground. I have some continuous rotation motors from a Vex robotics kit that I want to use with an Arduino or standalone AVR (the Vex controller isn't open source and is based on PIC's, I like AVR's more).

About This Instructable



Bio: I finally graduated from Missouri University of Science and Technology (Missouri S&T, formerly University of Missouri Rolla) with a computer engineering degree. Originally from ... More »
More by CalcProgrammer1:Cheap and Easy Tachometer (RPM Sensor) for Brushed DC Motors Cheap Home Automation using Wireless Outlet Modules ATTiny USI I2C Introduction - A powerful, fast, and convenient communication interface for your ATTiny projects! 
Add instructable to: