What exactly are you wanting to do? You said switch an output then off again when its ready but what makes it ready?
Hood
OK sorry for not explaining my self so i could have in the code G31 M31 , so this means that the machine is going to digitize the z axis and call a macro which i called it M31 so i don't confused with the others
now when i have G31 M31 in my code i want the machine to give a output and when the digitize led come active the output will go off that's all i need i been searching all day yesterday to find some thing similar but no luck