Dimming an LED Lamp With an Arduino




About: 2015 Autodesk AiR. I can't respond to messages here: please send me email!

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.



    • Classroom Science Contest

      Classroom Science Contest
    • Fandom Contest

      Fandom Contest
    • Gardening Contest

      Gardening Contest

    9 Discussions


    1 year ago

    Thanks for this great idea, it works a treat. One question however is when I put an amp meter on the incoming supply, the load varies from 110ma to 400ma depending on the PWM value I set. I expected it to be constant.


    1 year ago

    Sorry to resurrect an old thread, but what did you do for a power supply on the LED circuit?

    1 reply

    Reply 1 year ago

    Sorry I don't recall! May have been my bench power supply but any 12V
    power supply with enough current capacity will work. This was a 9W lamp
    so a 12VDC "wall wart" that can deliver 1 amp is more than enough.
    Depending on your LED lamp, even AC supplies can work.


    2 years ago


    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!


    3 years ago

    // 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);





    3 years ago on Introduction

    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?