My homebrew dimmer

Until recently pretty much all the ceilings in my house including the hallways were popcorn ceilings. This was popular in the 60's and 70's as a cost saving measure because the popcorn hid the minor defects that would be too obvious if regular paint was used. In fact when I bought this house in 1989 most of the popcorn was also covered in glitter, something that went out of style even more quickly than the plain popcorn. In 1989 I hired a painter to spray all the ceilings (except for one room) with white paint. So although the popcorn look still remained at least the dreadful glitter was gone. The popcorn including the one room with glitter remained until January 2026 when I hired a contractor to cover up all the ceilings with grooved paneling, using 1x6 molding strips to hide the seams and to give depth to the design. As part of this project, I also added modern recessed lighting.


I used the 4 inch lights shown on the left (purchased here in the bedrooms and hallways. These lights look elegant and are surprisingly bright for their size. The 4 inch lights would be fine for the rest of the house as well but I like very bright lighting so for the kitchen, family room and living room areas I chose the 6 inch lights shown on the right (purchased here). These 0-10V dimmable lights are also available in 8, 10, and 12 inch sizes but I didn't use them.

Most lights require only 3 wires to be hooked up to provide the 120VAC power in the US. (In many other countries 240AC power is used.) These wires are usually called hot, neutral, and ground. The hot and neutral wires provide the power and the ground connection provides additional safety for certain types of electrical failures. In older houses built before the 3rd wire grounds became part of the electrical code (like my house), only the hot and neutral wires need to be hooked up. If you wanted to dim the lights you would buy a dimmer switch that would chop the AC waveform to reduce the power going to the lights when you don't want the full brightness. These lights are different however. If you want to dim them you need two additional wires routed from the lights to the dimmer switch. The dimmer switch does not chop the AC power like most traditional dimmer switches but instead simply provides a 0-10V signal to the lights to control the brightness. (10V commands full brightness.) It can be a pain to run these two extra wires, but still these lights have become at least somewhat popular because it's a smoother and more efficient way to control the brightness and is never subject to flicker. (Flicker can be a problem with traditional dimmers and can be dramatically bad if the wrong dimmer is chosen for the type of lighting used.)


The dimmer switch I used (at least at first) is shown here and was purchased here. Note that this dimmer can't be used with the traditional 3 wire lights. It can only be used with the lights shown above or similar ones that advertise "0-10V dimming". I hooked up the dimmer wires from all four lights in the room to the dimmer switch as per the instructions. The dimmer worked, but I wasn't happy with the performance. When I moved the dimmer slider from the top to the middle of the range the lights dimmed by a barely noticeable amount. Even when I moved the slider down more to the 1/4 position the dimming amount was still quite small. So most of the control, from close to full brightness to off happened during the bottom 1/4 of the slider travel nearly wasting the top 3/4 of the travel range. This makes it touchy to adjust the brightness to the desired level. That was the defect that inspired me to design my own dimmer.

To explain the source of this defect, I'll digress slightly to discuss potentiometer tapers and our hearing and sight sensing capabilities. Our ears can detect sounds over 12 orders of magnitude from the threshold of hearing at 1 pico-watt/m2 to the threshold of pain at 1 watt/m2. To sense such a huge range of sound levels, our hearing sense almost has to be logarithmic. This means we can sense smaller changes in sound power when listening to quieter sounds than for louder sounds. To create a perceived doubling of the sound level we need to more than double the sound power exposed to our ears. (Typically we need to increase the sound level by a factor of 8 to 10 to get this perceived sense of twice as loud.)

If we plot the resistance of a typical potentiometer as a function of the knob angular position we get a plot such the one on the left. This is called a linear taper potentiometer. (It won't be this perfect, but this is the ideal.) It would not be ideal to use such a potentiometer to control the sound power to a speaker. The first half of the rotation would increase the sound level from zero up to pretty much the maximum because we don't hear much difference between max power and max/2. This means we are essentially wasting the 2nd half of the rotation. In most circuits, the potentiometer controls amplitude instead of power. Since power is proportional to the square of the amplitude, the control is improved somewhat but we can still get better control of the volume by using a different taper. Instead of a the linear resistance curve the resistance should increase exponentially.

As an example, let's look at the percent resistance vs. position of a slider potentiometer that I will later be using with my custom dimmer. It's spec sheet shows the chart on the right of resistance vs. position. Although it has nearly straight segments (which is common as it is probably easier to build) if you smooth that out in your mind it does look like it approximates an exponential curve. This is often called a log taper which is paradoxical because the transfer curve is the inverse of that. It gets that name because it is used to counter the logarithmic nature of our hearing. The term "audio taper" is also common which I think is better because it is not ambiguous or paradoxical. If you hook it up backwards, then the transfer curve is actually logarithmic and I've heard this referred to as exponential or reverse logarithmic both of which are paradoxical. (Perhaps reverse audio would be better.) The specific transfer curve shown in this chart is sometimes referred to as a 15% audio taper because the resistance is 15% of the maximum at the center position. (Values between 10 and 20% are the most common.)

Our eyes can see light over a dynamic range of about 5 orders of magnitude and, if given some time to adapt to low light levels we can see an additional 5 to 8 orders of magnitude. This suggest that when adjusting light intensity an audio taper would be appropriate for the same reason it is useful for sound intensity. It was surprising and annoying then that the dimmer switch I mentioned above did not use an audio taper. It appeared to be nearly linear and probably even curved somewhat in the wrong direction (i.e. reverse audio). Of course my own dimmer design would not suffer from that problem. It also occurred to me that it wouldn't be that much harder to put in a separate potentiometer for each light in the room rather than the traditional approach of controlling all the lights in the room with a single control. I did this partly because I thought it was cool. I did think it would be occasionally useful as well, and once these dimmers were installed I was surprised how often I adjusted the lights individually.

Here is a schematic of my six position dimmer which I installed in my family room and master bedroom. (The schematic for the four and two position dimmers is the same with some of the lights and sliders removed.)

The red lines represent the connections for the individual positive terminals of the 0-10V dimming signal and the black lines represent the negative terminals (common).

Since the wires of the 7 conductor cable are soldered to the flat ribbon cable with the 8 pin female IDC connector you might be wondering why the six 2 conductor cables could be soldered directly to the flat ribbon cable bypassing the need for the 7 conductor cable and all the JST connectors. Indeed that is possible but that would require feeding all six of the 2 conductor cables down from the attic to the box containing the switch. I found that feeding a single cable from the attic to the switch box was already one of the more difficult installation tasks and the thought of having to feed thru six different cables to the switch box was enough to dissuade me from that idea. So it was worth the time to construct the 7 conductor cable with the JST connectors on one end. One could also consider soldering the 2 and 7 conductor cables together bypassing the need for all the JST connectors. However that would require soldering in the attic which is not a very convenient place for such a task. Also it would be a nightmare if you ever have to replace one of the lights, whereas the JST connectors would make that task much easier.

I made some measurements that indicated that there is a constant current source in the lights which presents about 500uA to the dimmer wires with a maximum voltage of about 11.8V. This suggests that if we put a 20K potentiometer across this current source, the voltage on the dimmer wires will vary between 0 and 10V as the potentiometer is varied from 0 to 20K ohms. The dimmer circuit would work fine without the series 1.2K resister shown here. However as we reduce the voltage on the dimmer wires, the lamp is effectively off by the time the voltage decreases to about .7V which means we don't really need to adjust the potentiometer below about 1.4K. So adding the 1.2K resister improves the control at the low end and still allows the light to be turned completely off when the slider is moved to the bottom of its travel. BTW, the commercial dimmer switch from Allsmartlife shown above can't use a simple potentiometer circuit similar to my dimmer design. This is because the commercial dimmer is designed to work with multiple lights wired in parallel. So the commercial dimmer must use a more complicated design and I'm not exactly sure exactly how that design works.

I will now discuss the parts used starting at the top of the diagram and working our way down.

Since I have already discussed the lights, I'll start with the switch shown at the top right of the schematic. I bought the switches shown on the left because they were inexpensive and I liked the style and the fact that they are illuminated when the switch is off. Amazon also sells a single pole version (about 10% cheaper) as well as a single switch (for $9.69) if you don't need the 10 pack. This inexpensive switches worked well for the rooms with 4 or 6 lights (a total of 60 to 120 watts). But in the kitchen and hallways, with just 2 of the four inch lights (a total of 30 watts), these switches did not work well. They are still safe and effective in turning the lights on and off, however the switch illumination flickers. I believe this is because the switch was designed to be used with higher wattage lights. The flickering is not dangerous, but it is annoying, so in this low wattage situation I used the switch shown on the right. No flickering with those, the only drawback is that this switch is more expensive. The 120VAC power is connected to the lights and the switch using standard electrical practice appropriate for the electrical code in your area. (These lights and switches are also compatible with 240VAC and so no changes to this dimmer circuit are required if you live in a country that uses 240VAC house wiring.)


The six 12 foot cables coming from the (pink and purple) light dimming wires use this cable shown on the left. The picture on the right shows the 10 foot cable attached to one of the junction boxes that comes with each light. (The aluminum conduit going off the left side of the picture is attached to the lamp.) The black and white wires are connected to AC power with the two orange lug nuts, but this was just temporary to test out the lamp and dimmer circuit. Of course when installed the white and black wires would be feed thru a metal bushing inserted into one of the junction box openings. Although I used the black cable shown on the right (purchased here) for later builds, this was the first one I built and I used the white wire shown here which I happen to have laying around. The green wire normally goes to the third wire ground but my home is older and was not built with a third wire ground (except for a few circuits in the kitchen). So I just bundled up the green wire along with the pink and purple dimming wires to keep it out of the way.

As you would expect, I used the red wire of the 2 conductor cable as well as the red wire of the JST connectors (pictured below) for the positive 10V signal and the black wires for the ground (common). You might guess that the pink dimmer wire (which looks somewhat close to red) from the lamp should be connected to the red wire. But NO! The pink wire is actually the negative and so you should connect it to the black wire of the cable and the purple wire is the positive and should be connected to the red wire of the cable. (As you can see later, all the negative wires are connected together). If you reversed the pink and purple, the purple wires would be connected together and the dimmer circuit would not work. (In my opinion this was a poor choice of colors by the lamp manufacturer.)


As you can see from the picture on the right, the female JST connector is connected to the other end of the 12 foot 2 conductor cable coming from the light. During installation, all six of these female JST connectors will be gathered together near the light closest to the on/off switch where they will be connected to the male JST connectors attached to the 7 wire cable shown below. Although my diagram calls for all six of the 2 conductor cables to be 12 feet long I didn't actually build it that way. For a very large room a few of the cables might need to be even longer. Also the lamp closest to the switch doesn't really need a cable at all and the female JST connector could be connected directly to the pink and purple lamp dimming wires.
(JST connectors purchased here)



Next it's time to build the ten foot 7 conductor cable. I used the cable shown to the left and purchased here. On one side of the cable I attached 6 male JST connectors. The colored electrical tape just below each JST connector (on the picture to the right) are not covering up any electrical connection. The tape is just there to identify the six different lamps. On the other side of the ten foot cable I attached one of the IDC connectors shown below. I cut one of the cables in this set in half and used one end or the other, split the 8 wires apart on the ribbon cable, stripped the insulation and soldered it to the 7 conductors of the 10 foot cable and protected all the connections with shrink tubing. The first time I built this cable I attached the 8 pin ribbon cable before installation. However it was too difficult to thread the cable from the attach down to the switch box so I ended up cutting of the ribbon cable part, then twisted the 7 wires together to create the smallest footprint possible to snake the cable from the attic down to the switch box. Once the cable was sticking thru the switch box, I reattached (soldered) the ribbon cable and again protected it with shrink tubing.


Since I was planning on building and installing nine of these dimmers in my house I bought the 6 pack of ribbon cables shown to the left and purchased here. I cut each cable in half, so this pack would allow me to build 12 cables since I could use either end. As I mentioned above, the best construction technique was to thread the 7 conductor cable from the attic to the switch box next to the dimmer box and then solder the wires of the 7 conductor cable to 7 of the 8 wires on the flat ribbon cable using heat shrink tubing to insulate and protect each connection. The first time I built one of these dimmers I preplanned what each terminal of the 8pin IDC connector would be used for (i.e. which light would be controlled and which slider in the dimmer box would control that light). That was the reason for the colored tape in the figure above. But after the first time, I realized it was much simpler not to plan any of that ahead of time. This means that I didn't need the colored tape since any of the 6 JST connectors could be used to control any of the 6 lamps. This also meant that the six potentiometers (as well as the common ground) could be connected to any pin of the IDC connector at random. It was fairly easy to identify which connections needed to be made when soldering the 8 pin ribbon cable onto the 7 conductor wire (one wire at a time) to insure that the mapping between potentiometers and ceiling lights was logical.
The picture on the left shows the male IDC connector inserted into the hole in the side of the dimmer enclosure (and secured in place with a dab of epoxy). The cable shown above is inserted into this connector as the last assembly step. The IDC connector was purchased from Mouser. You can see it's part number and specifications here and it's mechanical drawing here. The picture at the right shows the flat ribbon cable attached to the dimmer enclosure as the cable snakes out of the switch box under the switch plate. Since you won't be yanking on this cable the strain relief isn't needed. I snipped the strain relief off with a diagonal cutter. This gives the connection a lower profile and allows the dimmer enclosure to be mounted closer to the switch.



I found that one of the difficulties of the commercial dimmers was that the slider used to control the brightness had such a small travel (around 18mm), one of the reasons it was so difficult to use. So I decided to use a slider with the longest travel I could find, which turned out to be the unit shown to the left (60mm travel). This slider has an audio taper which as I mentioned before also makes the brightness easier to adjust. You can download the spec sheet for this slider here.

Putting these knobs on the end of the slider makes it easy to adjust the sliders and results in a professional look. They can be purchased here


The 1.2K resistor wired in series with the slider is shown to the right and can be purchased here

Before moving on to the most interesting part of the design (the enclosure), I'll describe the fasteners used to secure the sliders to the enclosure. I knew I needed an M2 screw, but since I wasn't sure what length would be best I purchased this kit which includes a variety of sizes. It can be purchased here I found that any of the 3 smallest sizes worked well (3,4, and 5 mm lengths).

The kit had enough screws for all the dimmers I was building, but if I had known that 4mm was ideal I would have purchased these screws instead which are somewhat cheaper and the Philips head might have made assembly somewhat easier. here

I needed some flat head screws to mount the dimmer to the wall and I found this kit more than sufficient. It can be purchased here

The enclosure

The first dimmer I built was for my family room which had a row of four lights on one side of the room and a row of two lights on the other. I used the top of an electronics enclosure I happened to have and cut the slots for the sliders using a dremel tool. I had no experience using the dremel tool and this was my first attempt which of course looks terrible. If I was just going to build one I probably would have perfected my technique and tried again. However I was planning on building many of these dimmers, so this method was going to be too time consuming.

The obvious solution was to use 3D printing, but I knew the learning curve for mechanical design packages (such as FreeCAD, Autodesk, Onshape, etc.) was steep and I didn't want to spend that much time. In my research I stumbled on OpenScad, an open source programmatic mechanical design package. Since I'm a former programmer that made a lot of sense for me. Plus it is parametric making it easy to adapt the design. (For example for my living room dimmer which controls the lights in two rows of three lights, I only needed to make a trivial change to a single line of the family room dimmer design.)

I decided to start with a simpler 4 slider design for 3 bedrooms and the dinning area. Still I didn't even want to spend time finding and reading the OpenScad documentation, so I tried a shortcut. I opened a chatbox and entered this prompt:
    Create an OpenScad design of a hollow 2mm thick box without a top.
    The bottom of the box is 100 mm by 70 mm (outside dimensions).
    The height of the box is 15 mm (outside dimension).

    Place 8 holes and 4 slots centered in the bottom of the box in this arrangement:

      x  ------------  x

      x  ------------  x
 
      x  ------------  x

      x  ------------  x

    Each x represents a 2.3 mm diameter hole.
    The spacing between each pair of holes in a row is 71 mm.
    The spacing between each row is 13 mm.

    Each string of 12 dashes represent a horizontal slot measuring 65 mm by 2.2 mm
    that is centered between the two holes on either side.

I was pleased to see that the chatbox's response was c code. (I've written hundreds of c programs so I didn't have to learn any new syntax.) I copied the code from the chatbox into OpenScad and it immediately rendered something. The design didn't match my description but the mistakes were obvious and it didn't take me more than a few minutes to get a working design. I don't remember which chatbox I used, but it was just a free model. Perhaps if I had used a professional model it would have come up with the correct OpenScad code on the first try. I added one feature that wasn't in my chatbox design spec (rounded corners) and then I was basically ready to save the result as a .stl file to send to a 3d printing service. I was pleased that I was able to use my very first try although I manually countersunk the corner mounting holes so the screws would be flush with the surface. In my next iteration I added a countersink to the design and also 3D printed these three additional configurations: It was trivial to modify the original 4 slider design to accommodate 6 uniformly spaced sliders, but when I decided to add a larger gap between two of the sliders to delineate the two rows of lights my first attempt didn't compile. That's when I realized that OpenScad isn't exactly the same as c. Looking up the compile time error I realized that in fact OpenScad is a functional language. I had no experience with functional languages, but it took only a few tries to write something that the compiler would accept. Here is a table where you can download the OpenScad code and rendered .stl files for each design. (The .stl file is what you send to the 3D printing service). Click on any image to see a larger view.

# of sliders   .scad Code   .stl file image photo
2 download

view
download Click on any
image or photo for
a full size view
4 download

view
download
6 (4+2) download

view
download
6 (3+3) download

view
download
download

view
roundedcube
.scad
You must have this file on your path to
render any of the above .scad designs.
(used instead of the cube command)

Construction

The IDC connector is a press fit into the rectangular cutout in the enclosure but it isn't tight enough to hold it securely. So I used a few dabs of epoxy to hold it in place. Although it isn't strictly necessary, while I had the epoxy out I also used it to secure the wires and other components in place. Note that you must use pins 1 and 2 of the slider potentiometer. If you used pins 2 and 3, the slider would still control the intensity but the taper would reverse audio which would not be appropriate. (Imagine the taper curve shown above, but upside down.) The picture to the right shows the dimmer mounted to the right of the rocker switch. (In this case the dimmer had to be on the right side since there isn't room to mount it on the left side of the switch.) This is the dimmer I used in the family room and the master bedroom which both had a two rows of lights, one containing 4 lights and the other with 2 (shown in the third row of the table above.) A similar dimmer with two rows of 3 lights was used in the living room (shown in the forth row of the table).

In this case the dimmer had to be mounted on the left side of the rocker switch since there wasn't room on the other side. Notice that the sliders are mounted in the opposite direction compared to the six slider dimmer shown above. (This is necessary so that moving the slider up increases the brightness.) As I mentioned before, it is easiest to connect the wires at random to any pin on the IDC connector. This is most easily sorted out when attaching the female IDC cable to the 7 conductor cable. This was the dimmer used in the 3 bedrooms and the dinning area (shown in the second row of the table above.)

The simplest dimmer with just two sliders. The principles are the same, just fewer components. This was the dimmer used in the master bedroom hallway (on a 3 way switch) as well as in the kitchen. (Shown in the first row of the table above.)





Click on any photo
to see a larger image.


The six position dimmer shown above is used to control the lights in my family room pictured here. The four lights along the back wall are above the couch which can take advantage of a lot of lighting. The other side of the room has the TV and some shelving but no seating, so less light is needed there. This explains my choice of the 4 + 2 configuration. I find that when I'm alone in my favorite spot to read the newspaper, I have all the lights off except for the 2 lights directly above me. (My master bedroom uses the same 4 + 2 configuration except 4 inch lights are used instead of the 6 inchers shown here.)

Comparison

I made some measurements of the lamp's power vs. the slider position for my dimmer as well as the commercial dimmer I had purchased. First I plotted lamp power vs. the dimmer control voltage (shown to the left). This is for a single 6 inch light. This shows that the control voltage controls the lamp power approximately linearly with the maximum power achieved at about 8.3 volts. (Perhaps they should have called it "0 - 8 volt dimmable".) Of course a different manufacturer might not have the same transfer curve, although I suspect they would be similar. By the way, this data was collected by starting at the brightest end and slowly moving the sliders down to the dimmest end. I didn't collect any data for moving the slider in the opposite direction but I know that the results would be quite different. (This is called hysteresis.) In fact when starting at the bottom, one has to increase the control voltage to around 2 volts before the lamp turns on. (I forgot to measure that, so this is a guess.) This means the most significant dimming is only achieved by moving the sliders down. The script used to create this plot and the comparison charts below can be found here

Here I plotted lamp power vs. slider position for the two dimmers.

The left two traces are for the commercial dimmer and the right two traces are my dimmer (i.e. a 20K pot in series with a 1.2K resistor). The green traces are the measurements of the voltage across the dimmer control wires and the purple traces are measurements of lamp power.

The graph for my dimmer looks pretty much like the transfer curve shown on the slider spec sheet (reproduced in the graph near the top of this page). It has two more or less straight segments, but it does resemble an exponential at least somewhat. The commercial dimmer however looks like it bends the wrong way, i.e. a slightly logarithmic transfer curve (reverse audio taper). I also produced a plot similar to this one except using percent displacement on the x-axis instead of absolute distance. You can see that plot here

After using these dimmers for a while I've found that I rarely would bother dimming the lights unless I want a significant brightness reduction most often to with the 20 to 30% power range. Let's assume the useful dimming range is 10% to 40% power. (40% power is not really that dim, and 10% is about as low as you can go before the lamp turns off).

From this plot we can determine that when the commercial dimmer is moved from 40% down to 10% the slider changes position by 0.125". That's quite a tiny movement and explains why I was not very satisfied with this dimmer. However my homebrew dimmer moves 1.2" over the same power range That's bigger by a factor of 9.6 making the brightness so much easier to adjust. Much of that improvement comes from simply having a longer slider, but having a more appropriate taper is also a factor.

If you have any questions about this dimmer design, feel free to contact me at paul@mennen.org.