Making a Better Game
The Copycat game is good, but it doesn’t have a very good user interface. That is, you just have a bare piece of strip board, which looks very unfinished. You can do something about this, but first you have to learn how to control something a bit more powerful with the GPIO lines of the Raspberry Pi. The maximum current from any one GPIO pin is 16mA. Although this is good enough to light an LED, anything more and it’s just a bit feeble. The solution is to use the GPIO lines to control something that can switch more power, and the simplest thing that can achieve that is a transistor.
A transistor is a simple device for switching current. It has three terminals called the emitter, base, and collector. Their symbol is shown in Figure 16-6. It works by making a current flow through the base to the emitter: This is called the base current. When a base current flows, it causes another current to flow from the collector to the emitter. The trick is that this collector-to-emitter current you cause to flow in this way is the size of the base current multiplied by a gain factor, which can be as much as a few hundred times.
Figure 16-6: The transistor as a switch.
If you have a transistor with a gain of 200, and you put 15mA in the base, are you going to get a current of 15×200=000mA or 3A flowing? Not normally: The current you actually get depends on the power supply ...