I dont know whats wrong

So I am trying to make it so that when I press a button, lights will fade in and out then wait for me to press a button again. When i chect it is says its right but when i download it, it dosent work. Is the code messing it up?

const int ledPin2 = 5;
const int ledPin3 = 6;
const int ledPin4 = 9;
const int buttonPin = 2; // the number of the pushbutton pin
int buttonState = 0; // variable for reading the pushbutton status

void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
}

void loop() {

if (buttonState == HIGH) {

for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
analogWrite(ledPin2, fadeValue);
delay(100);
}

for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
analogWrite(ledPin3, fadeValue);
delay(50);
}

for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
analogWrite(ledPin2, fadeValue);
delay(0);
}

for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
analogWrite(ledPin4, fadeValue);
delay(50);
}

for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
analogWrite(ledPin3, fadeValue);
delay(50);
}

for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
analogWrite(ledPin4, fadeValue);
delay(50);
}

}}

Hi there!

On quick glance of your code, I see that there is no statement checking for the button press. Right before your if statement if(buttonState == HIGH), place the following line:

buttonState = digitalRead(buttonPin);

This should allow your code to run as you intend.

Good luck!

THANX, your amazing.

Sorry to bother you again but I did the thing and nothing happened again. Is something else wrong?