How to make if condition run once in while(1)
If I understand correctly you want to print it only once for each time the button is pressed, but as the controller will loop quite fast, currently for a single press you will have multiple prints.

So to get around that, you will have to save that you printed it, and as long as that is saved you don't print it. If the button is released you clear your saved variable, so that it gets printed again on the next button press.

Something like this:

bool printedOut = false;
while (true)
{
    if (switch == pressed)
    {
        if (!printedOut)
        {
            putsUART("switch 1 pressed");
            printedOut = true;
        }
    }
    else
    {
        printedOut = false;
    }
}


Note that this is prone to bouncing of the switch and you'll have to debounce the switch either in software or in hardware to really only get one print per press.