led fading using a single push button

guys please help me out in verifying my program for my project -- led dimming effect using push button.
my project is simple ....i want to start the led fading effect with one click on the push button that means glowing and dimming effect one after the another and on my second click the led should turn off.

now the problem is coming in the programming part because this is my first own hand project and i'm beginner at arduino so i'm getting problem in doing the right programming for my project.

THIS IS MY SKETCH :-

int ledpin = 9;
int pushbutton = 8;
int brightness = 0;
int fadeamount = 51;
int buttonstate = LOW;

void setup ()
{ 
  pinMode (ledpin,OUTPUT);
  pinMode (pushbutton,INPUT);
}

void loop ()
{ 
  if( digitalRead(pushbutton) == HIGH &&  butttonstate == LOW)
  { 
    digitalWrite (buttonstate,HIGH);
    analogWrite (ledpin,brightness);
    brightness = brightness + fadeamount ;
    delay (30);
    
    if ( brightness = 0 || brightness = 255 )
      { fadeamount = -fadeamount ; }
  }
  
   else 
   { buttonstate = digitalRead(pushbutton);
     digitalWrite(ledpin,LOW);
   }
}

plz suggest me changes in the program and the circuit diagram is given below in attachments.

A few problems there -

First the circuit, unless you led has in inbuilt resistor, you should use a 330 ohm resistor between pin 9 and the led, otherwise something will burn out.

Your code will not build in my Arduino ide; line -... buttonstate ==LOW , the error showing as "button state not declared" plus on the next line you try to DigitalWrite ( OUTPUT to PIN) .. buttonstate ?

You want to use the Arduino ide inbuilt Basic, Examples, 'FADE'
Get that running ok, then add your own variations as you understand the code better.

Well I changed a bit in my program ......I changed my analog output to brightness but still the way I wanted the program to work with my led, its not working in that way.

When I push the button the fading effect starts and when I leave the button the led gets off.

Actually I wanted my led to start the fading effect whenever I click the push button even after leaving it and I wanted to make it off on the next click..... but it is not happening in that way.

Arsh_Bansal:
Well I changed a bit in my program

Then please post the new code.

i have edited that in the previous code itself...

BEFORE :-
analogWrite (ledpin,HIGH);

AFTER :-
analogWrite (ledpin,brightness);