const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
// variables will change:
int buttonState = 0; 
int brightness = 255;
int fadeAmount = 5; 
void setup() {
  // put your setup code here, to run once:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}

void loop() {
    analogWrite(ledPin, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
  // put your main code here, to run repeatedly:
buttonState = digitalRead(buttonPin);
while(buttonState){
  int fadeAmount = 1; 
  analogWrite(ledPin, brightness);
  brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
}
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:

}
//excercises all except 5