LED ON OFF Macro or Toogle

  • Hey guys,

    I want to turn on or off the LED in my printer. I've done this multiple times using a LED ON and a LED OFF macro.

    I am using a DUET2 Wifi with the most current built of RRF 3.1.1. (will upgrade to 3.2 after the beta-phase is over).

    Is it possible to use a single macro with an if-statement or something like that to turn on/off the LED?

    Thanks for your help,

  • @MacNite how do you have your LED set up?
    Can you post the relevant sections of the config and then we can help you with the conditional gcode required

  • Hey - thank you for your help. I am on a business trip right now - so I do not have access to my printer.
    But the code I use is something like that:

    M950 P1 C"e1heat" Q500	;use heater 1 outupt for LED
    LED ON.g
    M42 P1 S1
    LED OFF.g
    M42 P1 S0

    Greets Max

  • something along the lines of this should work

    if state.gpOut[1].pwm == 1
       M42 P1 S0
       M42 P1 S1

  • Sorry for the late response.

    I tested the code and it works absolutley flawless!

    Thank you for your help!

  • hey, I would like to do exactly the same thing, I'm also on RRF3.1.1 but the gcode above doesn't work for me, it just turns the light on or off depending on what I enter, but I can't switch back and forth with one macro, do I need RRF3.2 or is it something else....

  • @MauriceM
    You need to wire your LED to the same pin as shown in the code

    When you say "back and forth", do you mean you want a single change or flashing ?

  • Yeah i changed the pin in the Command.

    My target is it to press the button and the light will go on, and when i press the button again the light turns off.

    But it does only one. depends on how i configure it.

  • @MauriceM Configure trigger for the button, and put this gcode in trigger#.g

  • I've done basically the same thing except, i've configured it as a fan, here's my code (include PSU Control)

    if fans[3].actualValue == 0
        M106 P3 S1.0
        M106 P3 S0
        M81 S1

Log in to reply