Change Feed Rate When Input High

I am trying to redo my tool probe macro to be a little bit safer and more efficient so I have a sensor above my plate to tell the machine to slow down when it arrives there. I could probe at 3 IPM from max Z height but that would take forever. The idea, since tool length will always be different, is to have the tool trip the sensor some distance above the plate and then the feed rate will change from rapid to the appropriate rate for probing. This is the relevant portion; copied from another guy:
Sensor input is on port 2, pin 9.
if(dodualcycle)
{
exec.Code("G31 Z" + Zmin + "F" + FeedrateFast); // Do the Z probing with Fast feedrate first
while(exec.IsMoving()){}
exec.Wait(200);
exec.Code("G91 G0 Z" + retractforsecondmeasurement);
exec.Code("G00 G53 X" + probeX2 +" Y" + probeY2); // Move to the second probe sensor position in XY
exec.Code("G90");
}
I need something like "when pin 9 goes high, exec.Code("F10");" or something. Basically emulating the speed override input on the run page. I want to crank the speed down to like 2% of normal once that input goes high (therefore the tool tip is about an inch above the probe plate).
Is that possible? I've been staring at the manual but so far I haven't come up with anything.
Thanks!
Sensor input is on port 2, pin 9.
if(dodualcycle)
{
exec.Code("G31 Z" + Zmin + "F" + FeedrateFast); // Do the Z probing with Fast feedrate first
while(exec.IsMoving()){}
exec.Wait(200);
exec.Code("G91 G0 Z" + retractforsecondmeasurement);
exec.Code("G00 G53 X" + probeX2 +" Y" + probeY2); // Move to the second probe sensor position in XY
exec.Code("G90");
}
I need something like "when pin 9 goes high, exec.Code("F10");" or something. Basically emulating the speed override input on the run page. I want to crank the speed down to like 2% of normal once that input goes high (therefore the tool tip is about an inch above the probe plate).
Is that possible? I've been staring at the manual but so far I haven't come up with anything.
Thanks!