CHAPTER 16 ■ TRANSISTOR SWITCHES
Because the gain varies from transistor to transistor (even within a batch), it isn’t reliable to design a
circuit based on a particular gain. Instead, make sure the circuit attached to the transistor limits its own
current below the transistor’s maximum as listed in the transistor’s datasheet. In this circuit, R7 and R8
protect the transistor as well as the LEDs.
Building the Brightness Comparator Circuit with Transistors
When building the circuit, leave a little room on the breadboard between the left and right indicators
(driven by Q7 and Q8) shown in Figure 16-10. Motors will be attached to the transistors in a future chapter.
The finished circuit should perform the same as the original brightness comparator circuit, but with the
addition of more LEDs. Wave your hand in front of the photoresistors to test it.
If any of the LEDs are backwards, the other LEDs in that strand won’t light. Interestingly, properly
installed LEDs light even with the transistor installed backwards. This is because not much gain is needed
yet. However, with the motors installed, a backwards transistor isn’t going to be able to supply enough
current to light the lights and engage the motors.
Summarizing PNP and NPN Transistors
When your robot needs to provide more power to a circuit than an ordinary chip can provide, attach a
transistor. When the chip is providing positive power, use an NPN transistor at the negative end of the circuit
you wish to control. Otherwise, use a PNP transistor at the positive end of the circuit you wish to control.
Transistors can turn all kinds of circuits and devices on and off. The examples in this chapter only
involved LEDs, but there’s no reason a variety of circuits couldn’t be attached to a transistor’s collector. In
fact, that’s how many power-saving devices are designed. When the brains decide enough idle time has
passed, the base current provided to various transistors is stopped, thus turning off unneeded circuits.
The line-following circuit is nearly complete. By connecting transistors to the comparator, you can
install three LEDs on both sides of the robot. In fact, the transistors drive enough current under the control
of the comparator that the board is now ready for motors.
Figure 16-10. Brightness comparator circuit with transistors built on a solderless breadboard