My circuit not Working.

When you do add those braces, I assume that you want them around both servo movements, as suggested by junwoo0914. (I accidentally left out the second movement in the code snippet I quoted.)

You really want this, but you'll need to read a different pin for the conditional:-
(Note the formatting.)

if (digitalRead(2) == HIGH)  // *** Not pin 2, it's the servo!
{
    for (pos = 0; pos <= 180; pos += 1)
    {
        myservo.write(pos);
        delay(15);
    }

    for (pos = 180; pos >= 0; pos -= 1)
    {
        myservo.write(pos);
        delay(15);
    }
}

An extra tip. To increment and decrement 'pos', it's quicker and easier to do this:-pos++orpos--rather thanpos+=1orpos-=1