Intro: 12v Neopixel RV Light
... or, how many makers does it take to change a lightbulb?
A 12V LED light in our camper van burned out for no obvious reason. I'm just learning how to use my new desktop CNC machine and wanted to try milling some different materials. So I thought I'd make a replacement that is more fun than just a basic light, using some Arduino hardware I had laying around for the guts.
The electronic internals are basically an Adafruit Metro arduino clone, a Bluefruit Easy-Link shield for reprogramming in place, and a neopixel shield. I've added a momentary button and a rotary encoder so you can dim/brighten the light, change colors, activate a little "mood light" rainbow show, and store power-on defaults in nonvolatile memory. Power is supplied via the neopixel shield from a buck converter which converts 12V shore power to the 5V required by the electronics.
This is my first Instructable so we'll see how this goes. I turned the above photo upside down so you can see how it will look installed.
Step 1: Design the Case in Openscad
I designed the case in layers like a cake using Openscad. I exported each layer of the 'cake' separately into individual .stl files by commenting out everything except the layer I was exporting. (I uploaded the Openscad file, the Arduino sketch, and the .stl files for the design in a zip file). The part where the actual work gets done looks like this:
explode_factor = 20;
Step 2: Mill or 3D Print the Individual Case Parts
After you've exported each of the case components to .stl files you can make each one depending on the equipment you have. I milled mine on a Carbide 3D Nomad Pro out of different materials. The "bottom_plate" is aluminum, the "acrylic_window" is (you guessed it) acrylic, the "bottom_layer2" is red oak, and the other parts are walnut.
This was my first aluminum on the Nomad and I was a bit aggressive with feeds and speeds (using the "some guy on the Internet said these ones worked for him" method). The mill stalled at one point and I let the job keep going, but as you may be able to see in the photo the machine needed to be re-zeroed after the stall. I didn't want to throw away the workpiece so I just ran it over with adjusted feeds and speeds. The flaws are not visible when the light is mounted anyway.
Step 3: Glue Together the Case Parts
Kind of self explanatory. There are dowel holes in the design to help everything line up and for structural strength.
I'm not really happy with how the glued-on Acrylic looks: if you look you may notice the glue when you look at the side-light because of the way it refracts. So one worthwhile modification would be to screw on the acrylic window instead of gluing it. Also, the side lighting effect could be different with more or less polishing of the milled part. I didn't do much.
Not shown is that I had to drill holes for the momentary button and encoder sideways on a drill press. For a 3D printed version you could include the holes in the print by removing the percent signs '%' from the front of the following lines of Openscad code:
// Holes for button and encoder -- probably drill these manually after milling
%translate([encoder_x,-1,bottom_slice-control_cavity/2]) rotate([-90,0,0]) cylinder(d=encoder_shaft_diameter,h=control_cavity_wall+2);
%translate([soft_button_x,-1,bottom_slice-control_cavity/2]) rotate([-90,0,0]) cylinder(d=soft_button_diameter,h=control_cavity_wall+2);
Step 4: Prepare the Bluetooth Programming Shield
The prototyping area of the bluetooth shield is used to connect the momentary button and rotary encoder. I used Arduino pins 2,3,4, and 5. 2 is connected to one side of the momentary button so that the sketch can power the Arduino down and wake it back up using a hardware interrupt via that button. (It turns out that the electronics draw tens of milliamps anyway, but in a different iteration or for a different application this might matter). One of the encoder pins is connected to Arduino D3 for interrupt functionality. The other encoder output and the built in momentary button in the encoder are connected to 4 and 5 respectively. The neopixel shield uses Arduino D6.
I brought out ground to three header pins and 5v power to one, but only the three grounds are actually used: one for each of the two momentary buttons and one for the encoder common.
These are headers so I can plug and unplug jumper wires with appropriate female connectors. This makes assembly and installation into the case much easier. Hopefully not disassembly and debug, haha.
One critical step is to pair the bluetooth shield to your computer before you close everything up in the case. It may be possible to hack it up a bit to bring out the pairing button, but I didn't do that. The bluetooth shield allows a paired computer to reprogram the Arduino wirelessly.
Step 5: Prepare the Neopixel Shield
Solder the terminal block onto the bottom of the neopixel shield, with the connections facing inward. Glue the buck converter to the bottom of the shield (I should probably have oriented it differently) and connect the buck converter output to the terminal block power input on the shield. Solder a DPST switch to the buck converter input, and solder whatever wires you need on the other side of the switch to connect to 12V power in your vehicle. I like being able to fully isolate the electronics from the vehicle, but technically you could get away with a SPST power switch. At full brightness and full white this draws just over an amp from 12V, so size your switch appropriately. I can't remember where I got mine but it is plenty beefy.
Step 6: Put the Electronics in the Case and Screw on the Bottom Plate
Again fairly self explanatory. I put some nylon spacers onto the top of the neopixel shield to stand it off from the acrylic window (not shown - well, you can sorta barely see them in the photo with the front of the neopixel shield showing in the upper right corner). The fit was pretty tight.
Step 7: Load the Arduino Sketch
Power up with 12 volts and use the Arduino IDE to load the sketch into the light fixture. You can follow the guide for the shield. The "Rotary" library I used for the rotary encoder can be found here. Everything else is standard Arduino or Adafruit libraries for their products. It is just a light, after all.
The functionality in the sketch I put together is as follows (though of course you can make the light fixture behavior whatever you want by writing your own sketch):
Power on/off with hard wired power switch. There is Arduino start delay here -- kind of like the delay in waiting for a florescent light to turn on.
Encoder knob has two modes: setting brightness and setting color. Push encoder button to toggle mode. Most counter-clockwise color is pure white. Most clockwise 'color' is a rainbow light show.
Momentary button: press to sleep (lights off) and wake (lights back on instantly in same state) without Arduino power up delay. Hold momentary button >3 seconds to store current brightness and color as power on default.
Step 8: Install in Your Vehicle
All you have to do is connect 12V power capable of up to 1.2 amps or so. You can see the kind of tacky plastic LED light that this replaced behind it in the photo.