LED Brightness Control Using PWM

pratidnyakanse
pratidnyakanse

 

Code

/*Paste your code here*/
void setup() {
  // put your setup code here, to run once:
pinMode(3, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  for(uint8_t i = 0; i <= 255; i++){
  analogWrite(3, i);
  delay(8);
  }
  for(uint8_t i = 255; i >= 0; i--){
  analogWrite(3, i);
  delay(4);
  }

}



 

Output

Photo of Output

Hardware Setup

 

 


 

Submit Your Solution

Note: Once submitted, your solution goes public, helping others learn from your approach!