Gcode to make LED Light flash on/off repeatedly



  • Hi I'm trying to make a LED flash on and off in a loop during a machine state.

    I have done this in the daemon.g file but noticing a long pause at the end of the part of the script that performs the light switch, while the rest of the daemon.g file is being looped through.

    if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed || !move.axes[3].homed ; if axes 0,1,2 and 3 are not homed do...
    	M42 P2 S0.4
    	M42 P1 S0
    	G4 P200
    	M42 P2 S0
    	M42 P1 S0.4
    	G4 P200
    	M42 P2 S0.4
    	M42 P1 S0
    	G4 P200
    	M42 P2 S0
    	M42 P1 S0.4
    	G4 P200
        
    elif state.status == "idle"
    	M42 P2 S0
    	M42 P1 S0
    

    Is there a way of creating a loop outside of the daemon.g file which I could reference to turn on or off with an M98 command, so the flashing light is more consistent?



  • Have you considered just using an LED that has a built-in flasher?

    Frederick



  • @fcwilt Hi Frederick, I'm using a WWRGB LED strip for it's range of colours, so would prefer to achieve this onboard the Duet. Cheers, Savvas

    One alternative is to increase the dwell time to match the time it takes to go through the rest of the code in the daemon.g file - making the flashing seem more consistent.


Log in to reply