Controlling the LED brightness using Potentiometer and Servo Library
Code
#include<Servo.h>
Servo myservo;
void setup(){
myservo.attach(9);
pinMode(A0,INPUT);
}
void loop(){
int potVal = analogRead(A0);
int val = map(potVal,0,1023,0,180);
myservo.write(val);
}
Output :
Code
#include<Servo.h>
Servo myservo;
void setup(){
myservo.attach(9);
pinMode(A0,INPUT);
}
void loop(){
int potVal = analogRead(A0);
int val = map(potVal,0,1023,0,180);
myservo.write(val);
}
Output :