If you go into the docs directory of mach4 and open the api docs there is an example there on how to use it, just change the input1 its using to the input you are using, but because you are waiting for a signal you must change the time setting to something more realistic or it will timeout too fast.
you will need to put this as the last line of the m3 function not last line of script.
DazTheGas