button_event:
while (PINA & (1 << 5)); // button is now pressed while (!(PINA & (1 << 5))); // button is now released button_event();
The two loops are busy loops that do not do anything inside. The first loop exits when the button is pressed, whereas the second loop exits when the button is released. You can insert another function call between the loops if you need to respond to the ``button is being pushed'' event.
Busy polling is relatively easy to code, but it suffers from one major problem: it is wasteful of processing resources. In addition, it is difficult to extend the code, due to its structure, to detect and respond to edge events of multiple buttons.