delay halts everything, so in effect your arduino is brain dead for 1 second, as soon as that second is up then it will react to whatever state the conditions dictate
softuino:
hmmm
but I want it to run only once and then stop when the trigger is set to LOW
there is the problem of the loop keeping running
So use a state variable that can be set when you read LOW and check if the state variable is set when you decide if you want to "run" whatever it is you are trying to run.
softuino:
I want to pin5 be HIGH while trigger is HIGH
and then go LOW when trigger goes LOW
but I don't want the loop to run more than once
So what you need is called signal edge detection; you want an action to occur on the transition from LOW to HIGH. Take a look at the example "StateChangeDetection" under the Digital category in the Arduino IDE.
Yes, that's your problem. I'ts caused by delay().
The solution is not to use delay, but keep track of the time elapsed since your last action ( digitalwrite(5,HIGH); ).
( See "blink without delay" in the getting started tutorials )