Introduction: Dimming an LED Lamp With an Arduino
So I've been happy with these inexpensive 12V LED bulbs from Cree available at amazon.com. At 9 watts, they are as bright as a 35 watt halogen, cheap, and relatively good color. Also they are easy to take apart and hack!
Here's an easy hack that lets you dim them smoothly and
fully. Though you can dim the 120V versions using a dimmer, it's not very linear, and hard to control remotely. Here's an easy way using PWM from an Arduino or any similar microcontroller.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Dissasemble the Fixture
The first step is to take apart the bulb by removing the three Philips screws on the front faceplate. They are small and you will need them again, don't lose them! Carefully remove the metal faceplate and the three plastic lenses to expose the circuit board with the three LEDs
Step 2: The Electronics
The trick is to use a FET (Field Effect Transistor) to bypass the driver current around the LEDs as shown in the schematic above.
A logic high from the arduino on pin 9 turns on the FET, and shunts the current through the FET rather than the LEDs (because the voltage drop across the low on-resistance of the FET is much less than Vf of the diodes). This does not bother the current source driving the LEDs: all it wants to do is deliver its set current (in this case, about an amp) and it doesn't care whether it's through the LEDs or the FET. I'm using an IRF840 (pdf datasheet) FET because I had one lying around from repairing some motor controllers, you can use any FET with a logic-level threshold like a IRF512. Any decent N-channel FET will work, make sure it is rated for at least 12V and 1 amp current. Here's one from Adafruit that will do the trick!
If you are used to voltage sources like batteries or DC power supplies, this circuit sounds wrong: won't the FET "short out" the driver? Well, yes it does; the trick here is that power LEDs are driven by a current source, which is completely fine to short. When the PWM signal turns on the transistor, the LED current is shunted around the LEDs by the transistor, turning them off. Because the current source doesn't have to do any work to maintain the current through the low Vds of the FET, essentially no energy is wasted.
Step 3: Soldering the FET Shunt Wires
So just solder the bypass wires to the LED driver terminals marked "+" (pink wire) and "-" (white wire) in the image above. (Note your markings/colors may be different.) Since the wires are soldered to a heatsink you might need to increase the heat on your soldering iron. (You *are* using a temperature-controlled iron, right?)
Connect the + wire to the drain of the FET and the - wire to the source. (If that sounds wrong, remember the "source" of a N-channel FET should be more negative than the drain. Think of it as a "source" of electrons -- which are negative!)
Step 4: The Completed Circuit
So here's the completed circuit showing the Arduino, the FET (with the test clips), the shut soldered to the LED board. I ran the shunt wires out between vanes of the heatsink so the lenses and front panels would fit, but left them off here for the picture. FOr this proof-of-concept I didn't to put this in an enclosure but you might want to: you can solder the FET directly to the Arduino or to a small piece of perfboard for a mechanically reliable solution.
Step 5: Video
Here's a video of the completed circuit working. Because Instructables does not reliably embed Flickr videos, here's a direct link to the video.