O'Reilly logo

Raspberry Pi For Dummies by Mike Cook, Sean McManus

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

9781118554234-fg1606.eps

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required