Introduction: 3D Printer RGB LED Feedback
When I was in high school I was a tad jealous that the Makerbot we owned, had RGB temperature feedback. After I learned enough, I decided to replicate the design and add more feedback capabilities. With this you can turn the lights off and on; change colors for pauses, temperature, prep, cleaning; or whatever you want really! This works with any 3D Printer with an Arduino or AVR board running Marlin Firmware. Click here to see the RGB LEDs working on my Robo 3D Printer:
Step 1: Tools/Materials
Tools:
Soldering Iron
Wire Strippers
(tools below recommended, but not required)
3D Printer w/ PLA
Diagonal Cutters
Rotary Tool/File
Helping Hands
Blade
Materials:
RGB LED Strip
3 NPN Transitors
9 Wire Ribbon Cable
Printed Circuit Board
Male/Female Headers
(below recommended, but not required)
Heat shrink Tubing
Step 2: Soldering - Transistor Board
Cut the female headers so that you have to sets of pins; one with 4 pins, and one with 5 pins. The two rightmost pins on the NPN transistors will be place next to each other in a line with the pins on the headers. The far left pins gets stretched all the way to the end of the board to be grounded.
Optional:
To make this look really clean, I used a blade and rotary tool to make the PCB as small as possible. And if you want, model and print an enclose that will house the board.
Step 3: Soldering - Wires/Headers
Split the 9 ribbon cable into 4 and 5 strand sets. I recommends the four strand set it the single red wire.
Cut the male headers to that you have 4 and 5 pin sets.
Solder the 4 pin male headers to the 4 strand ribbon cable. NOTE: the one on the LED strip might be different.
Solder the 5 pin male header to the 5 stranded cable on one side only. On the opposite end of the 5 stranded cable split the two outside wire away from the inner 3. Solder the inner three to a 3 pin female header. Solder the Outer two to a 2 pin female header.
I recommend making the negative lead on the wires to identify polarity.
Step 4: Wiring/Installing
I have a picture of a crude Illustrator drawing how this is suppose to be wired.
RAMPS:
Plug the 2 pin female header on the 5 stranded wire into Aux 12v near the X-Axis driver. Plug the 3 pin female adapter into pins 4,5,6 on the pins array labeled "servos."
Transistor Board:
Plug the other end of the 5 stranded wire into the 5 pin female end of the transistor board. NOTE: Ground (Negative) will be the only pin that doesn't line up with the 4 pin header. Plug the 4 pin adapter into the 4 pin female header with the red wire, positive, lined up with the 5 pin adapter positive wire.
LED Strip:
This one is easy. Just plug the other end of the 4 pin adapter into the 4 pins on the LED strip. NOTE: There is a spot that is labeled 12v, be sure that is the positive end of your 4 pin adapter.
Installation:
You can install if you have tested if your circuit is working, don't worry about which colors yet.
You can peel that adhesive off the back of the strip, or use clear tape to mount the lights on top of your printer. Tuck the box somewhere where your moving components will not bother the circuits.
Step 5: Coding - Configuration.h
Time to plug in. I am using another RAMPS board that is not attached to a printer, but it is not required for you to rip your 3D printer's motherboard out!
You will need a copy of Marlin that you run on your printer. If you haven't edited firmware ever I recommend finding marlin edited for your printer specifically. If your confidante enough here a link to the Marlin download: Marlin. For Robo 3D users: Robo 3D.
In configuration.h find #define TEMP_STAT_LEDS and un-comment it (remove the two forward slashes)
Step 6: Coding - Pins.h
Getting here is a little tricky.
On the right there's a drop down menu, and when you scroll down there a file called pins.h.
There you will make a copy of the existing definition and make your own for your motherboard number.
Mine is 33 so I put this:
#if MOTHERBOARD == 33
#define STAT_LED_RED 4
#define STAT_LED_GREEN 5
#define STAT_LED_BLUE 6
#endif
Step 7: Coding - Marlin_Main.cpp
Now for the big one.
The other coding steps had much less lines of code than this one so attached is a text file of the code I wrote.
Delete EVERYTHING between:
#ifdef TEMP_STAT_LEDS
#endif
and then paste what I wrote in the text file.
Then...SMASH that upload button!
Step 8: Coding - Debugging
The start up code I implemented will flash the lights in the order Red, Green, Blue (easy to remember...RGB LED strip) then all of them will turn on and the light will be White. The wiring I here made the Green flash first, then the Red, then the Blue. So I need to switch Red and Green, but we are ENGINEERS! We will not be switching the physical wire, instead we switch the pins in the code.
Re-upload and be sure you get Red, Green, then Blue.
Step 9: How to Use
Now that you debugged everything should be working!
I changed the lights based off the Target/Current temps of the extruder and the bed.
Bellow is the key of color for temps:
Set Bed to 0, Set Extruder to 0 (Start Up/Idle) = White
At Temperature (Printing) = White
Set Bed to 1 (Idle) = Off
Set Bed to 100 (Cleaning) = Yellow
Set Bed to 69 (1 below my printing bed temp)(Pause for Prep) = Cyan
Set Bed to 71 (1 above my printing bed temp)(Print w/ no lights) = Off
Set Bed to 5 (Cooling down) = Green when bed is less then 50
Set Bed to anything but [1,5,69,70], Extruder to 200+ (Heating) = Fade from blue to red based off temp
Set Bed to anything but [1,5,69,70], Extruder to 1 (not 0) Temp (Cooling) = Fade from red to blue based off temp
Step 10: Customizing Code (Coming Soon)
I'm still trying to figure out the best way to explain how to modify the code to get different colors than what I defined. I will be updating this step in the future.

Participated in the
Full Spectrum Laser Contest 2016

Participated in the
Arduino All The Things! Contest
31 Comments
Question 6 months ago on Introduction
Any one still watching this ? any tip to get the LEDs to respond to the Heated Bed ?
Thank-you
Wally
Answer 6 months ago
No longer watching this post unfortunately. Marlin has evolved a lot since this was made. If there is interest in it I'll see what I can do about the new marlin. As far as the heated bed you'd probably need to change the temp_stat parameter to watch the heated bed.
Reply 6 months ago
Hello
Thank-you for the reply
6 months ago
Retired, No coding experience,but with your tutorial and your video I found yesterday lol
I have been able to get my old Folgertech 2020 i3 to half way work, The extruder is fine the bed is not affecting the RGB`s but its ok I`ll try with that later, I am so Happy with this.
I wanted to Thank-you Mr Johnson for your time,effort and Video and Mr Thomas with your code my machine came to life !!! THe picture is my machine at idle.
Thank-you
Wally
5 years ago
Hi ! Thks for this amazing tutorial ! Do you think we can use 5v relay (5v vcc using servo pins and can support 12v on power) rather than NPN transistor (cause i have relay and not transistor)
Reply 2 years ago
If you use a relay then you will get the solid colors like red green blue, you will lack the Dimming and the heat up routine of changing colors as it gets warmer. .. You will only see RED BLUE GREEN no dimming
3 years ago
i tried compiling with all the changes and included the code by MarkR431 and ThomasW263 but the error -
'class Temperature' has no member named 'degBed'
Tip 3 years ago on Step 5
Just updated my firmware with this and found some inconsistencies with Marlin 1.1.9.
Coding Pins.h, no longer needs editing, but pins_Ramps.h needs the following added:
Find:
#ifndef BOARD_NAME
#define BOARD_NAME "RAMPS 1.4"
#endif
Underneath this, add:
#define STAT_LED_RED_PIN 4
#define STAT_LED_GREEN_PIN 5
#define STAT_LED_BLUE_PIN 6
Then use the updated code supplied by ThomasW263 in the post below
5 years ago
Updated code (Marlin_main) that works for my Marlin (1.1.5):
#if ENABLED(TEMP_STAT_LEDS)
//Virtual Variables
static millis_t next_status_led_update_ms = 0;
int t = 2;
int Rval = 1;
int Gval = 1;
int Bval = 1;
int LEDmax = 200;
int ExtTemp;
int BedTemp;
int ExtTarg;
int BedTarg;
//Static Colors
void off(){Rval = 0;Gval = 0;Bval = 0;}
void white(){Rval = LEDmax;Gval = LEDmax;Bval = LEDmax;}
void red(){Rval = LEDmax;Gval = 0;Bval = 0;}
void green(){Rval = 0;Gval = LEDmax;Bval = 0;}
void blue(){Rval = 0;Gval = 0;Bval = LEDmax;}
void yellow(){Rval = LEDmax;Gval = LEDmax;Bval = 0;}
void cyan(){Rval = 0;Gval = LEDmax;Bval = LEDmax;}
void magenta(){Rval = LEDmax;Gval = 0;Bval = LEDmax;}
void warmwhite(){Rval = 255;Gval = 103;Bval = 23;}
//Handle Led Stauts
void handle_status_leds(){
if (ELAPSED(millis(), next_status_led_update_ms)) {
next_status_led_update_ms += 500; // Update every 0.05s
for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) {
ExtTemp = thermalManager.degHotend(cur_extruder);
ExtTarg = thermalManager.degTargetHotend(cur_extruder);
BedTemp = thermalManager.degBed();
BedTarg = thermalManager.degTargetBed();
}
//Fade Leds On when starting up
if(Rval+Gval+Bval == 3){
//length of delay
for(int r = 0; r<LEDmax; r++){Rval = r;analogWrite(STAT_LED_RED_PIN, Rval);delay(t);}
for(int r = LEDmax; r>0; r--){Rval = r;analogWrite(STAT_LED_RED_PIN, Rval);delay(t);}
for(int g = 0; g<LEDmax; g++){Gval = g;analogWrite(STAT_LED_GREEN_PIN, Gval);delay(t);}
for(int g = LEDmax; g>0; g--){Gval = g;analogWrite(STAT_LED_GREEN_PIN, Gval);delay(t);}
for(int b = 0; b<LEDmax; b++){Bval = b;analogWrite(STAT_LED_BLUE_PIN, Bval);delay(t);}
for(int b = LEDmax; b>0; b--){Bval = b;analogWrite(STAT_LED_BLUE_PIN, Bval);delay(t);}
for(int w = 0; w<LEDmax; w++){Rval = w; Gval = w; Bval = w;analogWrite(STAT_LED_RED_PIN, Rval);analogWrite(STAT_LED_GREEN_PIN, Gval);analogWrite(STAT_LED_BLUE_PIN, Bval);delay(t);}
}
if((BedTarg == 71)||(BedTarg == 1)){off();}
if(BedTarg == 100){yellow();}
if(ExtTarg == 0){warmwhite();}
if((ExtTarg != 0)
&&(BedTarg != 1)
&&(BedTarg != 69)
&&(BedTarg != 71)
&&(BedTarg != 100)){
if((ExtTarg >= ExtTemp-TEMP_HYSTERESIS)
&&(ExtTarg <= ExtTemp+TEMP_HYSTERESIS)){white();}
else if((BedTarg == 5)&&(BedTemp <= 50)){green();}
else{
int MidTemp = (((EXTRUDE_MINTEMP)-40)/2);
if(ExtTemp < 40){blue();}
if(ExtTemp > EXTRUDE_MINTEMP){red();}
if((ExtTemp > 40)&&(ExtTemp < MidTemp)){
Rval = map(ExtTemp,40,MidTemp,0,LEDmax);
Gval = 0;
Bval = LEDmax;
}
if((ExtTemp > MidTemp)&&(ExtTemp < EXTRUDE_MINTEMP)){
Rval = LEDmax;
Gval = 0;
Bval = map(ExtTemp,MidTemp,EXTRUDE_MINTEMP,LEDmax,0);
}
}
}
//Write to LEDs
analogWrite(STAT_LED_RED_PIN, Rval);
analogWrite(STAT_LED_GREEN_PIN, Gval);
analogWrite(STAT_LED_BLUE_PIN, Bval);
}
}
#endif
Reply 4 years ago
Thanks a bunch, I just updated to Marlin 1.1.9 and didn't know my code was broken. Came here and found that you already fixed the problem! Thanks so much!
Reply 4 years ago
Thks for this code working for me, but not completly ... my pins are good (RED PIN is RED PIN, BLUE is BLUE and GREEN is GREEN, tested with M42) but i dont have the good colors at start ! is : green, blue, cyan, in your code is red, green, blue ... can you help me (marlin 1.1.7) ?
Reply 4 years ago
I have same issue, did you resolve it?
Reply 4 years ago
finally i used transistors ... working with relay but noisy ... ;)
Reply 5 years ago
This code came close to working for me, but put my Marlin / Skynet in an infinite loop, rebooting it over and over.. Was there something more to this code that I should have taken note of? thx for the contribution!
5 years ago
Hello!
I tried to follow your tutorial, but I'm having a few issues, first of all I have a more recent version of Marlin...
I activated both :
#define TEMP_STAT_LEDS
and
#define RGBW_LED
#if ENABLED(RGB_LED) || ENABLED(RGBW_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#define RGB_LED_W_PIN -1
#endif
But i get the error :
"TEMP_STAT_LEDS requires STAT_LED_RED_PIN or STAT_LED_BLUE_PIN, preferably both."
Any idea? I didn't found where to define these...
Reply 5 years ago
I have the same problem :/
Reply 5 years ago
Simply copy that lines from pins-RAMPS.h
#define STAT_LED_RED_PIN (your Pin-Number)
#define STAT_LED_BLUE_PIN 35 (your Pin-Number)
to your configuration.h. It should look like
#define TEMP_STAT_LEDS
#define STAT_LED_RED_PIN (your Pin-Number)
#define STAT_LED_BLUE_PIN (your Pin-Number)
Of course you have to replace (your Pin-Number) with your real Pin-number :)
Edit: STAT_LED_GREEN_PIN isn't implemented in Marlin yet (April, 27th 2018)
Question 5 years ago on Step 2
hy,
Its a great tutorial from you !!!!!!
Have you a schematic of de pcb what do have wired ?
5 years ago
Hi very good project, do you have the stl box ?
5 years ago
Hello, I have a card MKS 1.5, where can I connect the wire?