int led = 5;
int bright = 0 ;
int incr = 5;
int time = 50;
void setup() {
// put your setup code here, to run once:
pinMode(led, OUTPUT);
}
void loop() {
// brightness low to high, hight to low
//analogWrite function, pin no. 5 pr voaltage control krne lgega
analogWrite(led , bright); //pwm value write
delay(time);
bright+=incr;
if(bright<=0 || bright>=255)//because aurduino is 8 bit microcontroller
{
incr = -incr;
}
}