What does a transistor do?

It does one of two things: acts as a tiny on/off switch, or acts as a tiny amplifier.

How does it work?

It uses only the properties of different atoms to perform its functions.  Some atoms contain very loose electrons and are good conductors ( "n" type atoms) and some atoms hold their electrons more tightly, making them poorer conductors ( "p" type atoms).

Here is a drawing I made of a possible transistor...



Not all of the atoms are alike. Some have loose electrons and some dont .  We make transistors with three separate zones, as shown below...

The brown lines separate the different areas.  The two smaller areas are "n" zones and the large area is a "p" zone.  If you were buying this transistor, you would ask for an "npn" transistor.

Let's say that you applied a voltage to the left wire...


It couldn't get very far, because it would run into the "p" zone...


So if we make the middle wire a little bit positive,

The electrons in the neighborhood are attracted to the middle wire...

This creates a "bridge" for the original current to pass through...


As soon as the middle current is removed, the transistor is off again.  Here is the sequence.  When the green arrow goes all the way across and out, then the transistor is "on".  It is controlled by the voltage on the center wire.