The next step in the MMS Photo-inator project is to design a circuit to switch the light bulbs in the buttons on an off using transistors. The Raspberry Pi 2 can't provide enough power to make the lights bright enough but it can control electronic switches that allow a higher powered power source to turn the lights on.
Using transistors turned out to be very difficult to me. The concept of a transistor is pretty simple but actually getting a circuit working is not. I burned out several transistors trying different things. I have also read various sources to learn more about transistors but it does not seem to help. Last weekend, Royce from the Milwaukee Makerspace helped me build a circuit that worked. I'll try to document what I learned for my own edification.
Learn About Transistors (good luck)
Here are some links to learn more about how to use NPN transistors as a switch:
- https://learn.sparkfun.com/tutorials/transistors
- http://www.dummies.com/how-to/content/electronics-components-use-a-transistor-as-a-switc.html
- https://www.techhouse.org/~dmorris/projects/tutorials/transistor.switches.pdf
Transistorized Switching Circuit
The objective is to turn three individual light bulbs on and off from my Raspberry Pi using transistors. The basic circuit is shown below. Note that everything, 12v PSU, RPi, and lights share the same ground. This is important.
Transistors will be used as electronic switches to allow current from the 12v, 1.8A power supply to flow through the light bulbs. The Pi will send a 3.3v signal to the base pin on the transistor. This is the signal that tells the transistor to turn on the light bulb.
According to this site, the Raspberry Pi can safely put out a maximum of 16 mA per GPIO pin and a total of 50 mA on all GPIO pins. So, I have to be careful and limit the current from the Raspberry Pi to the base of the transistor to 16mA per transistor.
Transistor Specifications
The first thing to do was to determine the characteristics of the transistor my project needed. This site was helpful to determine what transistor to use.
The transistor has to handle the output from the power supply I will use -- 12v and 1.8A (max) -- to power the lights. Even though the lights only draw 0.25A, the PSU can put out 1.8A. I think it is possible for the transistor to draw the full current in some circumstances so I need a transistor that can handle the maximum current from the PSU. The parameter for current is called Ic(max) on the datasheets. The parameter for voltage is called VCEO (max). When I look at the datasheet for a transistor, it has to have characteristics that fall within these two specifications.
Finally, the amount of current that the base needs must be <= 16mA. This parameter is called IB. To determine the IB parameter, you have to find the formula on the datasheet. It is usually something like IC = X * IB. Basically, divide the current for the load by X to find the current to send to the base. In my case, the load current is 1.8A maximum. If, for example, a particular transistor has a formula of IC = 100IB, IB would be equal to 1.8A / 100 or 18mA.
Finding a Transistor
I was able to remove a couple of transistors from the circuit board using a soldering iron.
Resistor for the Base
Its important to prevent the transistor from pulling too much current from the Pi and damaging it. The Pi can be protected from this by placing a resistor between the Pi and the base pin. Determining the size resistor that is needed was a bit complicated.

This means that the voltage from the pin on the Pi needs to be lowered from 3.3v to 1.4v at 10mA (rounded up from 8 just to be safe). The resistor has to remove 3.3-1.4 or 1.9 volts. Using Ohm's law to calculate the resistance works like this:
R = V/I or
R = 1.9/0.01A or
R = 190 ohms.
Putting a 190 ohm resistor between the Pi GPIO pins and the base pins of the transistors should keep the Pi safe from pushing out too much current, while providing enough volts to activate the transistor.
I put a 180 ohm resistor (the 'space had a 180 or 220 ohm but no 190) in the circuit and connected the Pi's 3.3v output pin to the base. The light turned on!
That was a lot of work and very frustrating at times. I would have never made it this far without Royce. That is what is so great about the Milwaukee Makerspace. There is usually someone around who can help you through the rough spots.
Next, I need to remove some more resistors from the board and build a prototype of the complete MMS Photo-inator project.