17. LED Brightness Control Using Potentiometer

Back To All Submissions
Previous Submission
Next Submission

Solving Approach:

How do you plan to solve it?

 

 

Code

#define ledpin          9
#define analogReadpin   A0

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

void loop() {
  // put your main code here, to run repeatedly:
  int potensiometer_input = analogRead(analogReadpin);
  int brightness = (int)((potensiometer_input * 255.0) / 1023.0);
  analogWrite(ledpin, brightness);
}

Output

Video

Add video of output (know more)

 

 

 

 

 

Photo of Output

 

 

 

 

 

Was this helpful?
Upvote
Downvote