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.

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.

Comments

author
thethings (author)2016-05-27

Hello!

Nice work!

I tried this but the LEDs stay on no matter what, it doesn't matter if I send a high or low signal on the pin connected to the transistor gate.

I use a MKR1000 and the transistor is an IRF510 (http://www.vishay.com/docs/91015/sihf510.pdf). Do you know hat could be the issue? Thanks!

author
NestorN (author)2016-01-30

// i use this code it works fine

const int ledPin = 9; // the pin that the LED is attached to

void setup() {

// initialize the ledPin as an output:

pinMode(ledPin, OUTPUT);

}

void loop() {

for(int i=0; i<=255;i++)

{

analogWrite(ledPin, i);

delay(100);

}

}

author
alex_wood (author)2015-09-28

Good story to follow up!

And... Why did you solder the bypass wires to the LED driver terminals at the heatsink meanwhile it was more convenient to solder at the (exit from) driver side?

author
nitin4212 (author)2015-01-16

where is code .....

author
rotormind (author)nitin42122015-01-16

If you read the Instructable, I link to the Arduino PWM example. In the Arduino 1.5.3 software, example code can be found in the Files->Examples->Analog->Fading menu.

http://arduino.cc/en/Tutorial/PWM

HTH

author
seamster (author)2014-10-06

Nice work! Thanks for sharing this.

About This Instructable

60,716views

38favorites

License:

Bio: 2015 Autodesk AiR. I can't respond to messages here: please send me email!
More by rotormind:Ommatid Spherical Display: Electronics, Programming and InteractivityOmmatid Spherical Display: constructing the enclosure and optical globeAiR Work
Add instructable to: