Try making sleepUntilPinIs (and friends) volatile?