break void function when the condition is met

Do you have a pulldown resistor(10k) on pin 2?
Where do you turn the LEDs LOW?