I didn't planed to connect the laser directly to the direction pin, my idea is to connect it to a transistor's base leg. I upload the circuit I use. It works on printing but not on layer change the laser don't turn off. I find it strange a command works from manual command but not from gcode. Maybe there are some more lines in Marlin what I didn't find and it disables the M42 command. Please help me find a way to make it work.
Thanks
Thanks