How to eliminate Wait and While?

Start by understanding the blink without delay example.

Then add a FSM (Finite State Machine) using the case statement.

Then add, if still required, interrupts.

But do take it one step at a time.

Mark