All submissions

LED Brightness Control Using PWM

Solving Approach:

How do you plan to solve it?

 

 

Code

const int ledPin = 9;  
const int maxPWM = 255;

void setup() 
{
  pinMode(ledPin, OUTPUT);
}

void loop() 
{
  
  for (int duty = 0; duty <= maxPWM; duty++)
   {
    analogWrite(ledPin, duty);
    delay(2000 / maxPWM);  
  }

  
  for (int duty = maxPWM; duty >= 0; duty--) 
  {
    analogWrite(ledPin, duty);
    delay(1000 / maxPWM);  
  }
}




 

Output

 

Video

Add video of output (know more)

 

 

 

 

 

Photo of Output

Add a photo of your hardware showing the output.

 

 

 

 


 

Submit Your Solution

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