while () as wait

If this is really the way you want to accomplish it, change the logic ORs ( || ) to logic ANDs ( && ) . This will execute the while loop while all of the pins tested are high, but if one of them goes low, it will break. Keep in mind that while waiting with delay, the processor cannot do anything, as this may be a problem later on in development.

Edit: Bobnova got it first. Stupid iphone...