To add dimmable LEDs to my 3d printer, I bought some 24v LEDs strips from Amazon. Along with the strips I bought a high power dual mosfet driver board to be able to control the power going to the LEDs.
The following is the basic wiring diagram of the driver board:
Image by icstation.com
The load is the LED strip and the power comes straight from the 3d printer PSU 24v terminals. the PWM signal that switches the MOSFETs comes from PWM pins on the rpasberry PI. I have the GPIO pins here below:
When I built mine I chose to use PINS 32 and 34 as they were the easiest to get to. However any PWM pin is fine as long as you know what it’s called in the software. Here it’s GPIO 12.
Here’s a picture of the PINs on my board:
And here’s the other end connected to the MOSFET board:
Next was to install plugins in Octopi to be able to control the GPIO and in turn, the LED brightness. Below is a screen shot of the plugins and their configurations. The plugins I used were Enclosure and Custom Control Editor. First setup Enclosure plugin to control the GPIO port as below:
I used 100Hz to prevent flicker of the LEDs. You can try different values based on your preferences.
Once the port was defined, you can access it by issuing the gcode command ENC O1 S0 where ENC is for enclosure, O is for the outputs logical number as defined in the previous step, and S is the value in percentage. So S0 is off and S100 is full on.
Next I created buttons to control this from the Octoprint web interface. This uses the Custom Control Editor plugin. This plugin is great for commanding things like go to center of bed etc. Here I created buttons with the command above behind it to control the LEDs:
And that’s it!