As part of my printers I needed some lighting to be controlled by the Duet board itself (Mine is a Duet 2 WiFi 1.04). I've set up some 2N7000 transistors to be controlled on the gate by some unused heater pins on the expansion header.
The Gcode is below along with a picture of the specific pins I used to control each colour. Your red, green and blue might end up being in a different order than I have in the Gcode. I used a common cathode RGB strip light running on 12V.
I hope this helps a few people.
Additionally, it can be included in your config.g with the following line in misc at the end:
M98 P"/macros/rgb_lighting_setup.g" ; Include RGB Lighting macro in startup process
If there is no .g in the name when you upload the macro, don't include the .g in the M98.