Instead of connecting the loop switch between +5 and ground, which leaves the input "floating" and thus in an unpredictable state, I suggest connecting one end to ground, the other end to the input, and using INPUT_PULLUP in the pin setup to enable the internal pull up resistor. The loop input will indicate HIGH when it's broken, LOW normally.
Why does your sketch repeat exactly the same code three times?
Sorry for low-res image. It’s an improvised switch created by creating a loop of wire contacts around the insulation of another. When the wires are pulled they complete a circuit and provide power.
My version is a bit simpler. I have two contacts from my wires stripped down and bent into “J” hooks and contacting each other. I want my circuit to supply power once I pull the wires apart and they are no longer in contact.
My apologies! I was actually in a rush in posting this as I was heading out the door. I had been finagling with the code and ended up pasting a few too many times. Thank you for the tip! I’ll give it a try later!