How to add software-controlled LEDs to your 3D printer!

Hey, you know what all the cool kids are intothese days? LEDs.

You’ve got them in warm white, cool white, RGB full color, whatever you want, and once you have some on your 3D printer, not onlydo they light up your work area and the print itself, but you can also use them to showsome simple status information about what’s going on.

This is going to work for pretty much any3D printer, the wiring is super simple and you don’t even need to mess with firmwaresettings to have these LEDs automatically controlled by the printer in a somewhat intelligentfashion.

So follow along and learn what LEDs I liketo use, how to wire them into your 3D printer’s control board and which options you have makethem useful.

Let’s go! So let’s start out with what LEDs make sensefor us here.

You’re probably going to be powering theseLEDs from your printer’s built-in power supply, they don’t add a ton of load, sounless you’ve got a power supply that’s already struggling or you’re trying to addan obscene amount of LEDs, you’re probably going to be fine.

The LEDs most of you will think of are probablyLED strips, they’re a centimeter wide, they’re flexible, and have some double-sided tapealready applied on the back, so you can just stick them anywhere you want, bend them aroundcorners or even wrap them around aluminum profiles.

The LEDs themselves are these little guyson here, you can get them with different brightnesses, different shades of white or in any othersingle color and, of course, in RGB, which is basically a red, green and a blue LED combinedinto one, and you can control each color individually.

So the common LED strips are a good choice, they are incredibly cheap, you can get a five meter long spool for just a few bucks andyou can cut that into smaller sections every three LEDs.

Even though the sticky tape on the back doesadhere well when you stick them down, I like to add a dab of hotglue or superglue to theends to keep them in place permanently.

Another type I also really like are theseLED rings, they are originally intended to get that tacky BMW angel eye effect on yourcar, but because you can get them in different sizes, you’re going to find one that isthe perfect size to fit around your hot end.

These come on a rigid PCB, so you don’thave to worry about mounting too much, if you want, you can of course make a 3D printedadapter to fit stuff perfectly, but you can also just epoxy or zip-tie them to your carriage.

These have a nice, even light that highlightsdetails as they are being printed, but you definitely should not pick a ring that ismuch too large, since that will light up everything around your toolhead, but leave the very centerin the dark.

Now, those two run off of 12V so they’resomewhat specific to this use, another option I kinda like are basic LED spots, they comein the shape of a Halogen spot and these work really well if you have your 3D printer inany sort of an enclosure, you drill a few holes, pop ‘em in and basically hook themup like any other light fixture.

It’s a different approach, but just to throwit out there, there are always different options.

Now, how do you wire the LED strips and ringsup? The simplest way would be just to head overto your printer’s power supply, add a pair of wires and connect that straight up to yourLEDs.

If your printer is using a 24V power supply, which is somewhat common is nicer machines, you will need to add a small buck converterin line that will drop the 24V to 12, basically you hook up the input side to the power supply, adjust the potentiometer on them until the output has 12V, and then connect the rest.

So hooking stuff up directly might be perfectlyfine, as soon as you switch on the printer, the LEDs also light up, but you can go quitea bit further.

If you just want a simple switched LED thatis on when the hotend is hotend, so when the machine is working, you can try and see ifyour printer has a switched hotend cooling fan that turns off when the hotend is cold, don’t confuse that with the part cooling fan though, that’s different.

Usually the output for the hotend fan hasbit of extra capacity and you could wire some LEDs directly into that output, in parallelwith the fan.

It’s not really elegant, though.

So what you can do instead for full controlis to use a spare pin that’s routed out somewhere on the board.

You should be able to find a graphic likethis that shows which physical, exposed pins correspond to which Arduino pin numbers.

You can use both so called digital pins thateither only have a number or are called D12, D13 etc, or the analog pins should there beany spares, they are always called A1, A2 and so on.

On the RAMPS, you have all these pins, onthe RAMBo, there’s this extension header, the MKS Base has few pins next to the endstopconnectors – and, on many boards you can even use unused endstop ports or the pins on theLCD connector to get an few extra control signals.

But if you do that, keep in mind that thefirmware might already be configured to use those signals for their original purpose, which means we can’t easily use them for other stuff.

Your best bet is always to use spare pinsthat are otherwise unused.

Now, these pins are directly connected tothe microcontroller, so they can’t drive any significant load by themselves.

Instead, you’ll need to add some sort ofdriver module.

Of course, you can use the classic Arduinorelay module if you fancy that “clank” every time it turns on or off, but since we’reonly switching DC current with the same ground reference as the control board, a MOSFet doesthe job much better.

While, of course, you can use a bare MOSFetor even a bipolar transistor, using one of these ready-made boards gives you the allthe circuitry and screw connectors and they’re like 50ct each.

I’m going to be using this homemade boardfrom a few years ago, which does the exact same thing.

You connect your spare pin from the controlboard to “signal”, a spare ground to ground, you can also grab ground from the power supplyif you don’t have an extra one on the board, and then wire in your 12V supply on the inputand the LED on the output side.

The RGB strips only have a single positiveline, so you only have to hook that up once, but you do have to connect each individualcolor line to the negative output side of a switch module.

And that’s the hardware done! Now, actually, you can right away try outif the hardware is working by sending a single line of gcode to your printer – that is M42, P, then the pin number you used, and S255.

If you used an analog pin, you’ll need toget the according digital pin number according to this table.

And as a bonus, try the same thing with S126- if your pin can do pulse width modulation, the LED should now be at just below half brightnessand you’ll be able to dim it using any value between 0 and 255 for the S setting.

If the LED turned off completely, then thatpin can only do on and off, which, honestly, is still fine.

If you’re not getting any reaction fromthe LEDs at all, double-check your wiring and if that doesn’t help, maybe try a differentpin.

So we’ve got full control over the LEDsthrough the firmware, which is great, now how do we make them smart? Some firmwares like Smoothieware let you defineconditions when the printer should turn on or off certain things, but we’re just goingto weave the controls into every print’s gcode.

It’s simple, it’s automatic once it’sset up, but there are a few things to watch out for.

For the simplest implementation, we’re goingto use the start and end gcodes, but of course you can customize this however you want it, like if you have two extruders, have the printer light up differently for each one.

But to start out, we’re going to head intothe start and end gcode settings of your slicer.

Depending on how many LEDs you hooked up, you’ve got a ton of different options, I’m just going to walk you through what I’dset up for a ring light on the toolhead and an RGB LED strip somewhere else, illuminatingthe rest of the machine.

At the very start of a print, I want to indicatethat the printer is preparing and heating up, so I’ll add M42 S, then the pin forthe red part of the RGB strip, S255, and the same thing for the green, to mix yellow light.

Just to be sure, I’ll also add the gcodeto turn all other light off.

Then you’ll have the homing and autolevelingparts of the startup, and once that’s done, I want to switch it to a pure red.

Now, the important thing is to add an M400line before our next lighting-related gcode, because of some whacky logic, Marlin doesn’talways run gcode one line after another, but might run some stuff in advance as soon asit’s stored in its buffers, and the M400 will just say, ok, before you run anythingafter this, make sure that you are done with everything else.

And that includes homing or heating up.

So, M400, then M42 P, pin for green, S0 toturn it off.

Then we’ll have the M190 line, which pausesuntil the heated bed is hot, if you have one, and M109, same thing for the hotend.

So once those lines are done, the printerwill start the actual printjob, and for that I just like to have a nice, white light onthe entire machine, so another M400 just to be sure and then an M42 for the LED ring, the green and the blue part of the strip and you’re in bussiness! Now, once the print is done, we can actuallyuse the LEDs to tell us when the printbed is cold enough to remove a part.

So what usually works is this: You let yourprinter run whatever moves it does to move the bed forward and the printhead out of theway, and then we first set the LEDs to, for example, green, and then to blue once everthingis cool.

So first off, turn everything off but thegreen LEDs, then use M190 R25, or 30, and by using the R instead of what would usuallybe S and then the temperature, the printer now waits for the bed to cool down as well.

Now another M400, so at this point the bedis guaranteed to be at 25, 30, whatever degrees Celcius, M140 S0 to turn it off all the waywithout waiting, and your M42s to turn off green and turn on blue.

If you want, you can add a timer until theLED shuts off on its own, that is G4 S, and then the time in seconds, M400, and then theM42 to turn off whatever LED is still on.

So this is what the entire thing looks likenow: Even without an LCD we get a ton of information on what the printer is up to and you’llnever have to your phone as a flashlight again to get a better look at how your prints arelooking.

Again, all the materials are linked in thevideo description, it’s all pretty cheap stuff, so if you’re looking for a quickproject that’ll make you 3D printers cooler and more usable, give it a go! If you’re running into trouble, check theforums at discuss.

toms3d.

org, I think that’s the exact type of help and advice the forumsshould be ideal for.

If you found this video helpful, give it athumbs up, get subscribed to see more like it and if you feel like directly supportingthe channel, head over to Patreon to get access to monthly hangouts and more.

That’s it for today, thanks for watchingand I’ll see you in the next one!.

Leave a Reply