How can I control addressable RGB LEDS?

  • Happy New Year!
    Fellow DIY'rs, I'm reaching out to anyone that can steer me in the direction of how to make use of a fan connector or other output of the Duet2 or Duex5 to drive an Arduino that controls addressable RGB leds. I can work with arduino code, and understand electronics fairly well. I don't understand the Duet2 board's capability that well yet.

    I want to use them in my interior lighting and be able to change the color via a slider, macro or other web based methods using DWC. I have built a BLV MGN Printer complements of Mr. Ben Levi's design and it uses three neopixel (WS2812) rings on the front of the printer and they are driven by an arduino nano from the duet2's "conn_sd" pin 10. I'm guessing this is outputting I2C data. It works great and shows printer status.

    I've purchased a strip of 300 RGB leds and just playing around have them programmed to cascade, show rainbow colors etc. I have plenty of arduinos of various flavors, I just need some direction how to make the Duet send out I2C information on one of the outputs. Thanks in advance!

  • look here:

    Duet I2C

  • Thanks Slam, I'll have to try wrapping my head around this as it might be a bit over my skill level without a lot of research and I still might not get it. Would you happen to know which outputs on the Duet/Duex are able to send out I2C data? Are all of the various outputs carrying this data? If you have any examples or other links of maybe someone that has done this I'd much appreciate it.

  • the BLV interface doesn't use i2c, it uses the existing paneldue serial/JSON interface. you might look at the M150 command which controls addressable LEDS from Gcode

  • Thanks for the clarification, Daavery. I was googling tonight and found this: Github LED site and even an arduino sketch that looks doable using the M150 GCode. I could make some Macro's to change the lights. I guess where I'm puzzled is where to connect the arduino GPIO to the Duet. I'm guessing I have to use a particular output and make it available using the minus commands I've seen. Do you know?

  • @wkellyo

    Do a DotStar search here on the DUET3D forum. There are 18 messages related to using DotStar on the DUET controllers.


  • 3mm thanks for the pointers, I've never heard of them but there sure is a lot of good reading and seems to be better supported. I think I'll head that way.

  • @wkellyo

    Given the ease of programming the WS2812b type RGB LEDs in the arduino environment, here's what I've done:

    • set an output PIN for use with M42
    • Connect this output pin to an analog input pin of the arduino. In my case I use an ESP32 which can bé easily purchased.
    • Monitor the input of the arduino to see what values ​​it gives according to the values ​​set on the M42. Depending on whether it is 8 or 32 bits the sampling may be different
    • Decide what values ​​I use and why (Warm up, start, print, ....)
    • Program the Arduino with the FastLED library that will assign a color / effect according to the value of the input PIN
    • Write a macro in the DUET for each output value of the PIN that connects to the Arduino
    • Call the Macro in order to provoke the output by the DUET PIN which will be sampled by the Arduino and execute the code to put the LEDS in the color chosen in previous steps.
      I have it that way and set different scenarios for Standby, warming, cooling, calibrating, printing and off. I call macros from confit.g at printer startup or from G-code generated by Slic3r. Alternatively I can enable them from the PanelDue.

    Hope it helps as Google Translator helps me 😜

  • 1RI, thank you so much for the information, I figured there was a way that even I could understand, this really helps a lot and I even have a few ESP32's laying around besides Nano's, Unos and even a few Mega Arduino's.

  • @wkellyo
    glad that it served you.

  • @1ri , would you be willing to share code you have created? While I understand the concepts you've outlined, any specific code for an arduino, macros, etc. would sure help me out as I could see the examples. Maybe you could zip what you have into a single zip file and attach to this post or message me and I'll give you my email address. I'm not much of a programmer but by using examples, I can usually figure stuff out. Thanks so much in advance and if you chose not to, there's no harm in asking.

  • @wkellyo

    for sure,

    I attach a file with the .ino I use and a folder with the macros that send the value to pin P100 (GPIO1 on DUEX5) or duex.gp1 for RRF3.
    Once the arduino is programmed, it prints the value it receives from the Duet via the serial port by sending the M42 commands to it.
    This makes it easier to adjust the values that need to be compared with the Arduino to display each color using the serial monitor.

    As you can see, the comments inside the macros and the .ino file are in Catalan, as it is my native language, but Google Translator is quite efficient in Catalan. 😉

    best regards

    I put the link in my drive because I couldn't upload a zip file. If anyone can guide me in how to do it, I would be very grateful

    Zip File

    Solved!! Just read this post to see that ZIP files are not supported....

  • @1ri, Bless you! I took a look at the files and other than the task of translating (as you said Google should work very well) I am confident I can make it all work. I have a Duet2 and a Duex5 in my printer so I have lots of available outputs. My goal at first is to simply be able to turn the lights on and off and change the colors via DWC using macros which should be easy enough since you have provided the macros I can modify. I also will have to modify the Arduino code somewhat, probably make it even simpler. Later I may try making them animate when the printer is being used. Thank you so much again!


  • @wkellyo

    With this in mind, in a configuration like ours with Duet2 + DUEX, only PINs 100-103 are available on the GPIO & I2C connector in the DUEX5, which are not so many.

    In RRF3, which will be effective from now on, I use this command to set the PIN in order to be able to use it later with the M42 of the macros.

    M950 P0 C "duex.gp1", which may be the value of gp1 to gp3 depending on the GPIO to be used

  • I messed around with all this today and actually have it working. The Arduino file was a definite challenge as the translation wasn't perfect and I had several errors that had to be fixed. But, it works and now I can tweak it all out to my liking and install the LED strips into the bed light diffusers. Thanks again!


  • administrators

    I'm glad you got it working. FWIW, Duet 3 supports DotStar LED strips natively.

  • for reference adafruit DotStar LEDs are APA102(or SK98225) LEDs so any APA102 4 wire LEDS will work

Log in to reply