buttonState = digitalRead(buttonPin);
while(buttonState == HIGH)
{
// do something
}
That won't work because there is no way for buttonState to change once in the loop. In other words you have to read buttonState each time through the loop to detect the change.
buttonState = digitalRead(buttonPin);
while(buttonState == HIGH)
{
// do something
buttonState = digitalRead(buttonPin); // read the button
}
or something like this
while(digitalRead(buttonPin) == HIGH)
{
// do something
}