16. LED Brightness Control Using PWM

Back To All Submissions
Previous Submission
Next Submission

 

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

 

 


 

Was this helpful?
Upvote
Downvote