Friday, 29 January 2016

Controlling the LED brightness Using Potentiometer

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 :

No comments:

Post a Comment