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

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


Hey, you know what all the cool kids are into
these 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 only
do they light up your work area and the print itself, but you can also use them to show
some simple status information about what’s going on. This is going to work for pretty much any
3D printer, the wiring is super simple and you don’t even need to mess with firmware
settings to have these LEDs automatically controlled by the printer in a somewhat intelligent
fashion. So follow along and learn what LEDs I like
to use, how to wire them into your 3D printer’s control board and which options you have make
them useful. Let’s go! So let’s start out with what LEDs make sense
for us here. You’re probably going to be powering these
LEDs from your printer’s built-in power supply, they don’t add a ton of load, so
unless you’ve got a power supply that’s already struggling or you’re trying to add
an obscene amount of LEDs, you’re probably going to be fine. The LEDs most of you will think of are probably
LED strips, they’re a centimeter wide, they’re flexible, and have some double-sided tape
already applied on the back, so you can just stick them anywhere you want, bend them around
corners or even wrap them around aluminum profiles. The LEDs themselves are these little guys
on here, you can get them with different brightnesses, different shades of white or in any other
single color and, of course, in RGB, which is basically a red, green and a blue LED combined
into 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 and
you can cut that into smaller sections every three LEDs. Even though the sticky tape on the back does
adhere well when you stick them down, I like to add a dab of hotglue or superglue to the
ends to keep them in place permanently. Another type I also really like are these
LED rings, they are originally intended to get that tacky BMW angel eye effect on your
car, but because you can get them in different sizes, you’re going to find one that is
the perfect size to fit around your hot end. These come on a rigid PCB, so you don’t
have to worry about mounting too much, if you want, you can of course make a 3D printed
adapter to fit stuff perfectly, but you can also just epoxy or zip-tie them to your carriage. These have a nice, even light that highlights
details as they are being printed, but you definitely should not pick a ring that is
much too large, since that will light up everything around your toolhead, but leave the very center
in the dark. Now, those two run off of 12V so they’re
somewhat specific to this use, another option I kinda like are basic LED spots, they come
in the shape of a Halogen spot and these work really well if you have your 3D printer in
any sort of an enclosure, you drill a few holes, pop ‘em in and basically hook them
up like any other light fixture. It’s a different approach, but just to throw
it out there, there are always different options. Now, how do you wire the LED strips and rings
up? The simplest way would be just to head over
to your printer’s power supply, add a pair of wires and connect that straight up to your
LEDs. If your printer is using a 24V power supply,
which is somewhat common is nicer machines, you will need to add a small buck converter
in 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 perfectly
fine, as soon as you switch on the printer, the LEDs also light up, but you can go quite
a bit further. If you just want a simple switched LED that
is on when the hotend is hotend, so when the machine is working, you can try and see if
your 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 has
bit of extra capacity and you could wire some LEDs directly into that output, in parallel
with the fan. It’s not really elegant, though. So what you can do instead for full control
is to use a spare pin that’s routed out somewhere on the board. You should be able to find a graphic like
this that shows which physical, exposed pins correspond to which Arduino pin numbers. You can use both so called digital pins that
either only have a number or are called D12, D13 etc, or the analog pins should there be
any spares, they are always called A1, A2 and so on. On the RAMPS, you have all these pins, on
the RAMBo, there’s this extension header, the MKS Base has few pins next to the endstop
connectors – and, on many boards you can even use unused endstop ports or the pins on the
LCD connector to get an few extra control signals. But if you do that, keep in mind that the
firmware 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 pins
that are otherwise unused. Now, these pins are directly connected to
the microcontroller, so they can’t drive any significant load by themselves. Instead, you’ll need to add some sort of
driver module. Of course, you can use the classic Arduino
relay module if you fancy that “clank” every time it turns on or off, but since we’re
only switching DC current with the same ground reference as the control board, a MOSFet does
the job much better. While, of course, you can use a bare MOSFet
or even a bipolar transistor, using one of these ready-made boards gives you the all
the circuitry and screw connectors and they’re like 50ct each. I’m going to be using this homemade board
from a few years ago, which does the exact same thing. You connect your spare pin from the control
board to “signal”, a spare ground to ground, you can also grab ground from the power supply
if you don’t have an extra one on the board, and then wire in your 12V supply on the input
and the LED on the output side. The RGB strips only have a single positive
line, so you only have to hook that up once, but you do have to connect each individual
color line to the negative output side of a switch module. And that’s the hardware done! Now, actually, you can right away try out
if 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 to
get 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 brightness
and 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 that
pin can only do on and off, which, honestly, is still fine. If you’re not getting any reaction from
the LEDs at all, double-check your wiring and if that doesn’t help, maybe try a different
pin. So we’ve got full control over the LEDs
through the firmware, which is great, now how do we make them smart? Some firmwares like Smoothieware let you define
conditions when the printer should turn on or off certain things, but we’re just going
to weave the controls into every print’s gcode. It’s simple, it’s automatic once it’s
set up, but there are a few things to watch out for. For the simplest implementation, we’re going
to 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 into
the 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’d
set up for a ring light on the toolhead and an RGB LED strip somewhere else, illuminating
the rest of the machine. At the very start of a print, I want to indicate
that the printer is preparing and heating up, so I’ll add M42 S, then the pin for
the 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 gcode
to turn all other light off. Then you’ll have the homing and autoleveling
parts 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 M400
line before our next lighting-related gcode, because of some whacky logic, Marlin doesn’t
always run gcode one line after another, but might run some stuff in advance as soon as
it’s stored in its buffers, and the M400 will just say, ok, before you run anything
after 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 to
turn it off. Then we’ll have the M190 line, which pauses
until the heated bed is hot, if you have one, and M109, same thing for the hotend. So once those lines are done, the printer
will start the actual printjob, and for that I just like to have a nice, white light on
the 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 actually
use the LEDs to tell us when the printbed is cold enough to remove a part. So what usually works is this: You let your
printer run whatever moves it does to move the bed forward and the printhead out of the
way, and then we first set the LEDs to, for example, green, and then to blue once everthing
is cool. So first off, turn everything off but the
green LEDs, then use M190 R25, or 30, and by using the R instead of what would usually
be 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 bed
is guaranteed to be at 25, 30, whatever degrees Celcius, M140 S0 to turn it off all the way
without waiting, and your M42s to turn off green and turn on blue. If you want, you can add a timer until the
LED shuts off on its own, that is G4 S, and then the time in seconds, M400, and then the
M42 to turn off whatever LED is still on. So this is what the entire thing looks like
now: Even without an LCD we get a ton of information on what the printer is up to and you’ll
never have to your phone as a flashlight again to get a better look at how your prints are
looking. Again, all the materials are linked in the
video description, it’s all pretty cheap stuff, so if you’re looking for a quick
project that’ll make you 3D printers cooler and more usable, give it a go! If you’re running into trouble, check the
forums at discuss.toms3d.org, I think that’s the exact type of help and advice the forums
should be ideal for. If you found this video helpful, give it a
thumbs up, get subscribed to see more like it and if you feel like directly supporting
the channel, head over to Patreon to get access to monthly hangouts and more. That’s it for today, thanks for watching
and I’ll see you in the next one!

41 Comments

  • Ryan's Workshop

    Awesome video Tom!
    Okay, I am a newbie and I would like to add RGB lights to my mk2s. I'm having trouble deciding which mosfet to use or if it will even work or not. Will this mosftet work that I picked out? also a wiring diagram for the RGB lights would be super helpful. Any help would be great.

    https://www.aliexpress.com/item/RGB-LED-Light-Modulator-Programmable-PWM-Controller-for-Arduino-MOSFET-Module/32837854785.html?spm=a2g0s.13010208.99999999.277.JWmiPi

    If this mosfet wont work which one should I get for the RGB lights. or am I better off making one like Toms?

  • Julio Antonio Dominguez

    Could be possible for me to drive to you with my printer and get it all tune up with you? I have been trying for a while but still quality is not good.

  • Ole Urgast

    You may connect an input of an Wemos D1 (using level shifter) to a output-pin from the controller. It can send comand to a hue bridge turning all colored lights in the house to green, if print is ready…

  • ozcanison

    I know this video is a year old, but theres a few important details you've not mentioned in this video to get this to work.

  • MrLateraliss

    Is this something that is capable to do with a stock Anet A8 board? I don't think it has any spare pins like the boards you show. The back of the LCD board has a line of pins, but my knowledge of circuit boards is pretty much zero.

  • Viciente

    .. another extremely interesting video – thx a lot. is there any pins accessible on the ender 3 mobo to do this mods as described? would love to! πŸ˜‰

  • j f

    A word of caution. LEDs require a constant CURRENT, not constant voltage. So I reckon you either need LEDs which limit current (e.g. with a resistor), or you need a 12v LED Driver (e.g. 12v MR16 LED Driver) or if you are dealing with 24v (12v-24v Constant Current LED Driver). All available for around a $1 on aliexpress or ebay. Hooking 12v LEDs directly to 12v power supply may not be safe!

  • Gabe Nydick

    Thomas, how do you wire up full RGBW LEDs if you don't have a multi-channel mosfet? Your custom board has multiple breakouts, but I have a handful of single channel mosfets, just like the keyes one you showed.

  • Cesar Maldonado

    Thank you very much for your info, this is the best video about controlled led, I have been looking info about the gradually pritntig advance associated to a RGB led, is possible control like with the heating extruder?

  • Stefan VR

    i have to say tom is meanwhile the best youtuber dealing with 3d printing. very sympathetic, very professional and always very informative…so sind sie halt die deutschen πŸ˜‰ beste gΓΌsse

  • Gregory Ayres

    can you use a Rasberry Pi 3 b+ to still get the Status effected RGB. i plan on adding an octoprint and id like to maximize its useful ness without messing much with the MK3s board. i was going to power both standalone NOT using MK3s PSU

  • pfow2006

    awesome Thomas Sanlandrer you just showed me how to do some thing I have been pondering, but was hesitating at the idea of messing with the firmware, I didnt even know it could be done from the g code, thank you for this video.

  • Elvin Haak

    Is it not just possible to make it even easier by putting the inputs of some switches parallel to the the heater-outputs and fans?
    For example Blue for the heatbed, Red for the hotend-heater, White for the extruder-fan ?
    You can thus really easily see the status of the printing without having to do anything in the gcode or slicer. It just always works the same.

    Of course you can even see a brighter or dimmer light (red or blue) when the heaters are on and more white light when the extruder-fan runs faster (PWM signals amplified by your mosfet or transistors to your LED's)

    Seems like such an easy idea. Any problems to be expected in this aproach?

  • ERIC BZH RP 2.0

    hello Thomas I come to watch your video it is interesting but you can give me the plan and the tipon for the trancistor and the value of the recistances and the bramchement on the arduino card because I would like to edit thank you and see you soon

  • Joseph CAPORASO

    Hi, excellent video but I have a problem. I want to do this with my Tevo Little Monster. The motherboard is a MKS SBASE V 1.3 but configured with Smoothieware. I have no idea wich pins I can use and how I have to configure this in the config.txt file. I think I can use pins in EXP1 slot because it's a TFT screen and not a lcd panel but I am absolute not sure. Have you an idea? Thanks. Joseph

  • Henry

    Rather than using a buck converter to step down from 24v to 12v would it not be easier to cut 2 led strips and wire them in series such that the voltage is split across them and they get 12v each?

  • David Barrett

    great and simple control idea. I learned a lot of nuances about start and end g-code here including what looks like [parameters]. How about a tutorial using this "light control technique" with some kinda simple electronics to shut down printer at end of a job please?

  • Diamonddrake

    Pro tip, for 24v psu and 12v leds you can cut them in half and reconfigure them to be 2 12v in series dropping 24v without needing additional electronics or wasting power in such a circuit.

Leave a Reply

Your email address will not be published. Required fields are marked *